@@ -1,210 +0,0 @@ | |||||
package com.iformall.controller.basic; | |||||
import com.iformall.annotation.SystemControllerLog; | |||||
import com.iformall.common.Result; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.controller.base.BaseController; | |||||
import com.iformall.domain.po.BusinessCircleBase; | |||||
import com.iformall.domain.po.WxCouponOrder; | |||||
import com.iformall.domain.po.WxCreditHistory; | |||||
import com.iformall.domain.vo.WxCardSpendVo; | |||||
import com.iformall.enums.EnumShopStatus; | |||||
import com.iformall.service.*; | |||||
import io.swagger.annotations.ApiImplicitParam; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.*; | |||||
import java.util.Date; | |||||
import java.util.HashMap; | |||||
import java.util.Map; | |||||
/** | |||||
* @author | |||||
*/ | |||||
@RestController | |||||
@RequestMapping("map") | |||||
public class WxMapController extends BaseController { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Autowired | |||||
private WxShopService wxShopService; | |||||
@Autowired | |||||
private WxMerchantService wxMerchantService; | |||||
@Autowired | |||||
private WxRentContractService wxRentContractService; | |||||
@Autowired | |||||
private WxCouponOrderService wxCouponOrderService; | |||||
@Autowired | |||||
private WxCardSpendService wxCardSpendService; | |||||
@Autowired | |||||
private WxBusinessCircleOrderService wxBusinessCircleOrderService; | |||||
@Autowired | |||||
private AliBusinessCircleOrderService aliBusinessCircleOrderService; | |||||
@Autowired | |||||
private WxCreditHistoryService wxCreditHistoryService; | |||||
@ApiOperation("根据id查询接口") | |||||
@GetMapping("/findShopBySid") | |||||
@ApiImplicitParam(name = "sid", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
@SystemControllerLog(description = "店铺管理-id查询") | |||||
public ResultData findShopBySid(String sid) { | |||||
logger.debug("[" + getIpAddr() + "] WxMapController::findShopBySid"); | |||||
Map<String, Object> resultObject = new HashMap<>(); | |||||
Map<String, Object> wxShopObject = wxShopService.detailBySid(getTenantInfo(), sid); | |||||
Map<String, Object> wxMerchantObject = new HashMap<>(); | |||||
Map<String, Object> wxRentContractObject = new HashMap<>(); | |||||
if(wxShopObject != null && !wxShopObject.isEmpty() | |||||
&& EnumShopStatus.RENT.getCode().toString().equals(wxShopObject.get("status").toString())){ | |||||
//已出租 | |||||
long shopId = Long.parseLong(wxShopObject.get("id").toString()); | |||||
String shopNumber = wxShopObject.get("shopNumber").toString(); | |||||
wxMerchantObject = wxMerchantService.detailByShopId(getTenantInfo(), shopId); | |||||
if(wxMerchantObject != null && !wxMerchantObject.isEmpty()){ | |||||
long merchantId = Long.parseLong(wxMerchantObject.get("id").toString()); | |||||
wxRentContractObject = wxRentContractService.currentValidByMerchantId(getTenantInfo(),merchantId,shopNumber); | |||||
} | |||||
} | |||||
resultObject.put("wxShop",wxShopObject); | |||||
resultObject.put("wxMerchant",wxMerchantObject); | |||||
resultObject.put("wxRentContract",wxRentContractObject); | |||||
return new ResultData(Result.SUCCESS, "查询成功", resultObject); | |||||
} | |||||
@ApiOperation("根据id查询接口") | |||||
@GetMapping("/findStatisticsBySid") | |||||
@ApiImplicitParam(name = "sid", value = "sid", dataType = "Long", paramType = "query", required = true) | |||||
@SystemControllerLog(description = "店铺管理-id查询") | |||||
public ResultData findStatisticsBySid(String sid, Date startDate, Date endDate) { | |||||
logger.debug("[" + getIpAddr() + "] WxMapController::findStatisticsBySid"); | |||||
Map<String, Object> resultMap = new HashMap<>(); | |||||
Map<String, Object> wxShopObject = wxShopService.detailBySid(getTenantInfo(), sid); | |||||
if(wxShopObject != null && !wxShopObject.isEmpty() | |||||
&& EnumShopStatus.RENT.getCode().toString().equals(wxShopObject.get("status").toString())){ | |||||
//已出租 | |||||
long shopId = Long.parseLong(wxShopObject.get("id").toString()); | |||||
Map<String, Object> wxMerchantObject = wxMerchantService.detailByShopId(getTenantInfo(), shopId); | |||||
if(wxMerchantObject != null && !wxMerchantObject.isEmpty()){ | |||||
long merchantId = Long.parseLong(wxMerchantObject.get("id").toString()); | |||||
WxCouponOrder wxCouponOrder = new WxCouponOrder(); | |||||
wxCouponOrder.updateTenantInfo(getTenantInfo()); | |||||
wxCouponOrder.setMerchantId(merchantId); | |||||
wxCouponOrder.setStartTime(startDate); | |||||
wxCouponOrder.setEndTime(endDate); | |||||
wxCouponOrderService.statisticsWriteOff(wxCouponOrder,resultMap); | |||||
WxCardSpendVo wxCardSpend = new WxCardSpendVo(); | |||||
wxCardSpend.updateTenantInfo(getTenantInfo()); | |||||
wxCardSpend.setMerchantId(merchantId); | |||||
wxCardSpend.setStartdate(startDate); | |||||
wxCardSpend.setEnddate(endDate); | |||||
resultMap.put("sumRealPayment",wxCardSpendService.sumRealPayment(wxCardSpend)); | |||||
BusinessCircleBase businessCircle = new BusinessCircleBase(); | |||||
businessCircle.updateTenantInfo(getTenantInfo()); | |||||
businessCircle.setMerchantId(merchantId); | |||||
businessCircle.setStartTime(startDate); | |||||
businessCircle.setEndTime(endDate); | |||||
Integer wxCircleSumPayment = wxBusinessCircleOrderService.sumCirclePayment(businessCircle); | |||||
Integer aliCircleSumPayment = aliBusinessCircleOrderService.sumCirclePayment(businessCircle); | |||||
resultMap.put("sumCirclePayment",wxCircleSumPayment + aliCircleSumPayment); | |||||
WxCreditHistory wxCreditHistory = new WxCreditHistory(); | |||||
wxCreditHistory.setTenantId(getTenantInfo().getFinalTenantId()); | |||||
wxCreditHistory.setMerchantId(merchantId); | |||||
wxCreditHistory.setStartTime(startDate); | |||||
wxCreditHistory.setEndTime(endDate); | |||||
resultMap.put("sumCreditAmount",wxCreditHistoryService.getIncrementCreditAmount(wxCreditHistory)); | |||||
} | |||||
} | |||||
return new ResultData(Result.SUCCESS, "查询成功", resultMap); | |||||
} | |||||
@ApiOperation("根据id查询接口") | |||||
@GetMapping("/findShopById") | |||||
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
@SystemControllerLog(description = "店铺管理-id查询") | |||||
public ResultData findShopById(Long id) { | |||||
logger.debug("[" + getIpAddr() + "] WxMapController::findShopById"); | |||||
return new ResultData(Result.SUCCESS, "查询成功", wxShopService.detailById(this.getTenantInfo(),id)); | |||||
} | |||||
@ApiOperation("根据id查询接口") | |||||
@GetMapping("/findMerchantByShop") | |||||
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
@SystemControllerLog(description = "店铺管理-id查询") | |||||
public ResultData findMerchantByShop(Long shopId) { | |||||
logger.debug("[" + getIpAddr() + "] WxMapController::findMerchantByShop"); | |||||
return new ResultData(Result.SUCCESS, "查询成功", wxMerchantService.findMerchantByShop(shopId)); | |||||
} | |||||
@ApiOperation("根据id查询接口") | |||||
@GetMapping("/findRentByShop") | |||||
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
@SystemControllerLog(description = "店铺管理-id查询") | |||||
public ResultData findRentByShop(Long shopId) { | |||||
logger.debug("[" + getIpAddr() + "] WxMapController::findRentByShop"); | |||||
return new ResultData(Result.SUCCESS, "查询成功", wxRentContractService.findRentByShop(shopId)); | |||||
} | |||||
@ApiOperation("根据id查询接口") | |||||
@GetMapping("/findStatisticsByShop") | |||||
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
@SystemControllerLog(description = "店铺管理-id查询") | |||||
public ResultData findStatisticsByShop(Long shopId, Date startDate, Date endDate) { | |||||
logger.debug("[" + getIpAddr() + "] WxMapController::findStatisticsByShop"); | |||||
Map<String, Object> resultMap = new HashMap<>(); | |||||
Map<String, Object> merchantByShop = wxMerchantService.findMerchantByShop(shopId); | |||||
if(merchantByShop != null && merchantByShop.get("id") != null){ | |||||
String tenantId = merchantByShop.get("tenant_id").toString(); | |||||
String parentTenantId = ""; | |||||
if(merchantByShop.get("parent_tenant_id") != null){ | |||||
parentTenantId = merchantByShop.get("parent_tenant_id").toString(); | |||||
} | |||||
Long merchantId = Long.parseLong(merchantByShop.get("id").toString()); | |||||
WxCouponOrder wxCouponOrder = new WxCouponOrder(); | |||||
wxCouponOrder.updateTenantInfo(getTenantInfo()); | |||||
wxCouponOrder.setMerchantId(merchantId); | |||||
wxCouponOrder.setStartTime(startDate); | |||||
wxCouponOrder.setEndTime(endDate); | |||||
wxCouponOrderService.statisticsWriteOff(wxCouponOrder,resultMap); | |||||
WxCardSpendVo wxCardSpend = new WxCardSpendVo(); | |||||
wxCardSpend.updateTenantInfo(getTenantInfo()); | |||||
wxCardSpend.setMerchantId(merchantId); | |||||
wxCardSpend.setStartdate(startDate); | |||||
wxCardSpend.setEnddate(endDate); | |||||
resultMap.put("sumRealPayment",wxCardSpendService.sumRealPayment(wxCardSpend)); | |||||
BusinessCircleBase businessCircle = new BusinessCircleBase(); | |||||
businessCircle.updateTenantInfo(getTenantInfo()); | |||||
businessCircle.setMerchantId(merchantId); | |||||
businessCircle.setStartTime(startDate); | |||||
businessCircle.setEndTime(endDate); | |||||
Integer wxCircleSumPayment = wxBusinessCircleOrderService.sumCirclePayment(businessCircle); | |||||
Integer aliCircleSumPayment = aliBusinessCircleOrderService.sumCirclePayment(businessCircle); | |||||
resultMap.put("sumCirclePayment",wxCircleSumPayment + aliCircleSumPayment); | |||||
WxCreditHistory wxCreditHistory = new WxCreditHistory(); | |||||
wxCreditHistory.setTenantId(getTenantInfo().getFinalTenantId()); | |||||
wxCreditHistory.setMerchantId(merchantId); | |||||
wxCreditHistory.setStartTime(startDate); | |||||
wxCreditHistory.setEndTime(endDate); | |||||
resultMap.put("sumCreditAmount",wxCreditHistoryService.getIncrementCreditAmount(wxCreditHistory)); | |||||
} | |||||
return new ResultData(Result.SUCCESS, "查询成功", resultMap); | |||||
} | |||||
} |
@@ -1,113 +0,0 @@ | |||||
package com.iformall.controller.market; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.annotation.SystemControllerLog; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.controller.base.BaseController; | |||||
import com.iformall.domain.po.AliBusinessCircleOrder; | |||||
import com.iformall.domain.po.WxBusinessCircleOrder; | |||||
import com.iformall.domain.po.base.BaseEntity; | |||||
import com.iformall.service.AliBusinessCircleOrderService; | |||||
import com.iformall.utils.Constant; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiImplicitParam; | |||||
import io.swagger.annotations.ApiImplicitParams; | |||||
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.GetMapping; | |||||
import org.springframework.web.bind.annotation.ModelAttribute; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.util.HashMap; | |||||
import java.util.Map; | |||||
@RestController | |||||
@RequestMapping("aliCircle") | |||||
@Api(description = "订单相关接口") | |||||
public class AliBusinessCircleOrderController extends BaseController { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Autowired | |||||
private AliBusinessCircleOrderService aliBusinessCircleOrderService; | |||||
@ApiOperation("分页列表接口") | |||||
@GetMapping("list") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||||
}) | |||||
@SystemControllerLog(description = "-列表") | |||||
public ResultData list(@ModelAttribute AliBusinessCircleOrder circleOrder, Integer pageNum, Integer pageSize) { | |||||
logger.debug("[" + getIpAddr() + "] AliBusinessCircleOrderController::list"); | |||||
if (null == circleOrder) { | |||||
circleOrder = new AliBusinessCircleOrder(); | |||||
} | |||||
circleOrder.updateTenantInfo(getTenantInfo()); | |||||
circleOrder.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||||
final PageInfo<AliBusinessCircleOrder> page = aliBusinessCircleOrderService.listAsPage(circleOrder, pageNum, pageSize); | |||||
return new ResultData(page); | |||||
} | |||||
@ApiOperation("统计接口") | |||||
@GetMapping("statistics") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||||
}) | |||||
@SystemControllerLog(description = "-统计") | |||||
public ResultData statistics(@ModelAttribute AliBusinessCircleOrder circleOrder) { | |||||
logger.debug("[" + getIpAddr() + "] AliBusinessCircleOrderController::statistics"); | |||||
if (null == circleOrder) { | |||||
circleOrder = new AliBusinessCircleOrder(); | |||||
} | |||||
circleOrder.updateTenantInfo(getTenantInfo()); | |||||
Integer sumPayAmount = aliBusinessCircleOrderService.sumCirclePayment(circleOrder); | |||||
Integer sumRefundAmount = aliBusinessCircleOrderService.sumCircleRefundAmount(circleOrder); | |||||
Map resultMap = new HashMap(); | |||||
resultMap.put("sumPayAmount",sumPayAmount); | |||||
resultMap.put("sumRefundAmount",sumRefundAmount); | |||||
return new ResultData(resultMap); | |||||
} | |||||
@ApiOperation("详情接口") | |||||
@GetMapping("detail") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true) | |||||
}) | |||||
public ResultData detail(String orderId) { | |||||
if (StringUtils.isBlank(orderId) || orderId.equalsIgnoreCase(Constant.UNDEFINED)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
} | |||||
Long id; | |||||
try { | |||||
id = Long.valueOf(orderId); | |||||
} catch (NumberFormatException e) { | |||||
logger.error(e.getMessage()); | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "orderId: " + orderId + ", e: " + e.getMessage()); | |||||
} | |||||
AliBusinessCircleOrder order = aliBusinessCircleOrderService.detail(id,getTenantInfo()); | |||||
return new ResultData(order); | |||||
} | |||||
@GetMapping("exportData") | |||||
@SystemControllerLog(description = "券订单数据-导出数据") | |||||
public void exportData(@ModelAttribute AliBusinessCircleOrder circleOrder, HttpServletRequest request, HttpServletResponse response) { | |||||
logger.debug("[" + getIpAddr() + "] AliBusinessCircleOrderController::exportData"); | |||||
if (null == circleOrder) { | |||||
circleOrder = new AliBusinessCircleOrder(); | |||||
} | |||||
circleOrder.updateTenantInfo(getTenantInfo()); | |||||
circleOrder.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||||
aliBusinessCircleOrderService.exportData(circleOrder, request, response); | |||||
} | |||||
} |
@@ -1,109 +0,0 @@ | |||||
package com.iformall.controller.market; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.annotation.SystemControllerLog; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.controller.base.BaseController; | |||||
import com.iformall.domain.po.*; | |||||
import com.iformall.domain.po.base.BaseEntity; | |||||
import com.iformall.service.*; | |||||
import com.iformall.utils.Constant; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiImplicitParam; | |||||
import io.swagger.annotations.ApiImplicitParams; | |||||
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.*; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.util.HashMap; | |||||
import java.util.Map; | |||||
@RestController | |||||
@RequestMapping("wxCircle") | |||||
@Api(description = "订单相关接口") | |||||
public class WxBusinessCircleOrderController extends BaseController { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Autowired | |||||
private WxBusinessCircleOrderService wxBusinessCircleOrderService; | |||||
@ApiOperation("分页列表接口") | |||||
@GetMapping("list") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||||
}) | |||||
@SystemControllerLog(description = "-列表") | |||||
public ResultData list(@ModelAttribute WxBusinessCircleOrder circleOrder, Integer pageNum, Integer pageSize) { | |||||
logger.debug("[" + getIpAddr() + "] WxBusinessCircleOrderController::list"); | |||||
if (null == circleOrder) { | |||||
circleOrder = new WxBusinessCircleOrder(); | |||||
} | |||||
circleOrder.updateTenantInfo(getTenantInfo()); | |||||
circleOrder.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||||
final PageInfo<WxBusinessCircleOrder> page = wxBusinessCircleOrderService.listAsPage(circleOrder, pageNum, pageSize); | |||||
return new ResultData(page); | |||||
} | |||||
@ApiOperation("统计接口") | |||||
@GetMapping("statistics") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||||
}) | |||||
@SystemControllerLog(description = "-统计") | |||||
public ResultData statistics(@ModelAttribute WxBusinessCircleOrder circleOrder) { | |||||
logger.debug("[" + getIpAddr() + "] AliBusinessCircleOrderController::statistics"); | |||||
if (null == circleOrder) { | |||||
circleOrder = new WxBusinessCircleOrder(); | |||||
} | |||||
circleOrder.updateTenantInfo(getTenantInfo()); | |||||
Integer sumPayAmount = wxBusinessCircleOrderService.sumCirclePayment(circleOrder); | |||||
Integer sumRefundAmount = wxBusinessCircleOrderService.sumCircleRefundAmount(circleOrder); | |||||
Map resultMap = new HashMap(); | |||||
resultMap.put("sumPayAmount",sumPayAmount); | |||||
resultMap.put("sumRefundAmount",sumRefundAmount); | |||||
return new ResultData(resultMap); | |||||
} | |||||
@ApiOperation("详情接口") | |||||
@GetMapping("detail") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true) | |||||
}) | |||||
public ResultData detail(String orderId) { | |||||
if (StringUtils.isBlank(orderId) || orderId.equalsIgnoreCase(Constant.UNDEFINED)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
} | |||||
Long id; | |||||
try { | |||||
id = Long.valueOf(orderId); | |||||
} catch (NumberFormatException e) { | |||||
logger.error(e.getMessage()); | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "orderId: " + orderId + ", e: " + e.getMessage()); | |||||
} | |||||
WxBusinessCircleOrder order = wxBusinessCircleOrderService.detail(id,getTenantInfo()); | |||||
return new ResultData(order); | |||||
} | |||||
@GetMapping("exportData") | |||||
@SystemControllerLog(description = "券订单数据-导出数据") | |||||
public void exportData(@ModelAttribute WxBusinessCircleOrder circleOrder, HttpServletRequest request, HttpServletResponse response) { | |||||
logger.debug("[" + getIpAddr() + "] WxBusinessCircleOrderController::exportData"); | |||||
if (null == circleOrder) { | |||||
circleOrder = new WxBusinessCircleOrder(); | |||||
} | |||||
circleOrder.updateTenantInfo(getTenantInfo()); | |||||
circleOrder.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||||
wxBusinessCircleOrderService.exportData(circleOrder, request, response); | |||||
} | |||||
} |
@@ -6,8 +6,6 @@ import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
import com.iformall.domain.po.AliBusinessCircleOrder; | |||||
import com.iformall.domain.po.WxBusinessCircleOrder; | |||||
import com.iformall.domain.po.WxCoupon; | import com.iformall.domain.po.WxCoupon; | ||||
import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
import com.iformall.domain.po.WxPressBatch; | import com.iformall.domain.po.WxPressBatch; | ||||
@@ -19,8 +17,6 @@ import com.iformall.enums.EnumCouponChannelType; | |||||
import com.iformall.enums.EnumCouponContentType; | import com.iformall.enums.EnumCouponContentType; | ||||
import com.iformall.enums.EnumCouponSourceType; | import com.iformall.enums.EnumCouponSourceType; | ||||
import com.iformall.enums.EnumCouponType; | import com.iformall.enums.EnumCouponType; | ||||
import com.iformall.enums.EnumRentContractAppStatus; | |||||
import com.iformall.service.AliBusinessCircleOrderService; | |||||
import com.iformall.service.WxCouponChannelService; | import com.iformall.service.WxCouponChannelService; | ||||
import com.iformall.service.WxCouponService; | import com.iformall.service.WxCouponService; | ||||
import com.iformall.service.WxPressBatchService; | import com.iformall.service.WxPressBatchService; | ||||
@@ -1,126 +0,0 @@ | |||||
package com.iformall.controller.market; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.annotation.SystemControllerLog; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.controller.base.BaseController; | |||||
import com.iformall.domain.po.WxThirdPartyOrders; | |||||
import com.iformall.domain.po.base.BaseEntity; | |||||
import com.iformall.enums.EnumThirdOrderType; | |||||
import com.iformall.service.WxThirdPartyOrdersService; | |||||
import com.iformall.utils.Constant; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiImplicitParam; | |||||
import io.swagger.annotations.ApiImplicitParams; | |||||
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.GetMapping; | |||||
import org.springframework.web.bind.annotation.ModelAttribute; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.util.HashMap; | |||||
import java.util.Map; | |||||
@RestController | |||||
@RequestMapping("thirdCircle") | |||||
@Api(description = "订单相关接口") | |||||
public class WxThirdPartyOrdersController extends BaseController { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Autowired | |||||
private WxThirdPartyOrdersService wxThirdPartyOrdersOrderService; | |||||
@ApiOperation("分页列表接口") | |||||
@GetMapping("list") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||||
}) | |||||
@SystemControllerLog(description = "-列表") | |||||
public ResultData list(@ModelAttribute WxThirdPartyOrders circleOrder, Integer pageNum, Integer pageSize) { | |||||
logger.debug("[" + getIpAddr() + "] WxThirdPartyOrdersController::list"); | |||||
if (null == circleOrder) { | |||||
circleOrder = new WxThirdPartyOrders(); | |||||
} | |||||
circleOrder.updateTenantInfo(getTenantInfo()); | |||||
circleOrder.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||||
final PageInfo<WxThirdPartyOrders> page = wxThirdPartyOrdersOrderService.listAsPage(circleOrder, pageNum, pageSize); | |||||
return new ResultData(page); | |||||
} | |||||
@ApiOperation("统计接口") | |||||
@GetMapping("statistics") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||||
}) | |||||
@SystemControllerLog(description = "-统计") | |||||
public ResultData statistics(@ModelAttribute WxThirdPartyOrders circleOrder) { | |||||
logger.debug("[" + getIpAddr() + "] AliBusinessCircleOrderController::statistics"); | |||||
if (null == circleOrder) { | |||||
circleOrder = new WxThirdPartyOrders(); | |||||
} | |||||
circleOrder.updateTenantInfo(getTenantInfo()); | |||||
Integer sumPayAmount = wxThirdPartyOrdersOrderService.sumCirclePayment(circleOrder); | |||||
Integer sumRefundAmount = wxThirdPartyOrdersOrderService.sumCircleRefundAmount(circleOrder); | |||||
Map resultMap = new HashMap(); | |||||
resultMap.put("sumPayAmount",sumPayAmount); | |||||
resultMap.put("sumRefundAmount",sumRefundAmount); | |||||
return new ResultData(resultMap); | |||||
} | |||||
@ApiOperation("详情接口") | |||||
@GetMapping("detail") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true) | |||||
}) | |||||
public ResultData detail(String orderId) { | |||||
if (StringUtils.isBlank(orderId) || orderId.equalsIgnoreCase(Constant.UNDEFINED)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
} | |||||
Long id; | |||||
try { | |||||
id = Long.valueOf(orderId); | |||||
} catch (NumberFormatException e) { | |||||
logger.error(e.getMessage()); | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "orderId: " + orderId + ", e: " + e.getMessage()); | |||||
} | |||||
WxThirdPartyOrders order = wxThirdPartyOrdersOrderService.detail(id,getTenantInfo()); | |||||
return new ResultData(order); | |||||
} | |||||
@GetMapping("exportData") | |||||
@SystemControllerLog(description = "券订单数据-导出数据") | |||||
public void exportData(@ModelAttribute WxThirdPartyOrders circleOrder, HttpServletRequest request, HttpServletResponse response) { | |||||
logger.debug("[" + getIpAddr() + "] WxThirdPartyOrdersController::exportData"); | |||||
if (null == circleOrder) { | |||||
circleOrder = new WxThirdPartyOrders(); | |||||
} | |||||
circleOrder.updateTenantInfo(getTenantInfo()); | |||||
circleOrder.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||||
circleOrder.setSourceType(EnumThirdOrderType.RMB_PAY.getCode()); | |||||
wxThirdPartyOrdersOrderService.exportData(circleOrder, request, response); | |||||
} | |||||
@GetMapping("exportDataVo") | |||||
@SystemControllerLog(description = "券订单数据-导出数据") | |||||
public void exportDataVo(@ModelAttribute WxThirdPartyOrders circleOrder, HttpServletRequest request, HttpServletResponse response) { | |||||
logger.debug("[" + getIpAddr() + "] WxThirdPartyOrdersController::exportDataVo"); | |||||
if (null == circleOrder) { | |||||
circleOrder = new WxThirdPartyOrders(); | |||||
} | |||||
circleOrder.updateTenantInfo(getTenantInfo()); | |||||
circleOrder.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||||
circleOrder.setSourceType(EnumThirdOrderType.CREDIT_PAY.getCode()); | |||||
wxThirdPartyOrdersOrderService.exportDataVo(circleOrder, request, response); | |||||
} | |||||
} |
@@ -138,27 +138,6 @@ public class BaseMyBatisConfiguration { | |||||
wxCUserFromSharding.setRule(EnumShardingRule.HASH.getCode()); | wxCUserFromSharding.setRule(EnumShardingRule.HASH.getCode()); | ||||
shardingList.add(wxCUserFromSharding); | shardingList.add(wxCUserFromSharding); | ||||
ShardingSphere wxBusinessCircleOrderSharding = new ShardingSphere(); | |||||
wxBusinessCircleOrderSharding.setColumn("tenant_id"); | |||||
wxBusinessCircleOrderSharding.setTableName("wx_business_circle_order"); | |||||
wxBusinessCircleOrderSharding.setCount(100); | |||||
wxBusinessCircleOrderSharding.setRule(EnumShardingRule.HASH.getCode()); | |||||
shardingList.add(wxBusinessCircleOrderSharding); | |||||
ShardingSphere aliBusinessCircleOrderSharding = new ShardingSphere(); | |||||
aliBusinessCircleOrderSharding.setColumn("tenant_id"); | |||||
aliBusinessCircleOrderSharding.setTableName("ali_business_circle_order"); | |||||
aliBusinessCircleOrderSharding.setCount(100); | |||||
aliBusinessCircleOrderSharding.setRule(EnumShardingRule.HASH.getCode()); | |||||
shardingList.add(aliBusinessCircleOrderSharding); | |||||
ShardingSphere wxThirdPartyOrdersSharding = new ShardingSphere(); | |||||
wxThirdPartyOrdersSharding.setColumn("tenant_id"); | |||||
wxThirdPartyOrdersSharding.setTableName("wx_third_party_orders"); | |||||
wxThirdPartyOrdersSharding.setCount(100); | |||||
wxThirdPartyOrdersSharding.setRule(EnumShardingRule.HASH.getCode()); | |||||
shardingList.add(wxThirdPartyOrdersSharding); | |||||
ShardingSphere wxOrderSharding = new ShardingSphere(); | ShardingSphere wxOrderSharding = new ShardingSphere(); | ||||
wxOrderSharding.setColumn("tenant_id"); | wxOrderSharding.setColumn("tenant_id"); | ||||
wxOrderSharding.setTableName("wx_order"); | wxOrderSharding.setTableName("wx_order"); | ||||
@@ -1,28 +0,0 @@ | |||||
package com.iformall.domain.po; | |||||
import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
import com.baomidou.mybatisplus.annotation.TableName; | |||||
import lombok.Data; | |||||
import lombok.EqualsAndHashCode; | |||||
import lombok.ToString; | |||||
@TableName(value = "ali_business_circle_order") | |||||
@Data | |||||
@ToString(callSuper = true) | |||||
@EqualsAndHashCode(callSuper = true) | |||||
public class AliBusinessCircleOrder extends BusinessCircleBase { | |||||
@io.swagger.annotations.ApiModelProperty(value="发生交易的商圈(非商圈组)的商圈唯一标识号",name="mallId") | |||||
private String mallId; | |||||
@io.swagger.annotations.ApiModelProperty(value="发生交易的商圈(非商圈组)的名称",name="mallName") | |||||
private String mallName; | |||||
@Excel(name = "门店编码", width = 20, orderNum = "1") | |||||
@io.swagger.annotations.ApiModelProperty(value="门店编号,商户侧系统内编号",name="mallStoreId") | |||||
private String mallStoreId; | |||||
@io.swagger.annotations.ApiModelProperty(value="支付宝用户Id",name="buyerId") | |||||
private String buyerId; | |||||
} |
@@ -1,141 +0,0 @@ | |||||
package com.iformall.domain.po; | |||||
import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
import com.baomidou.mybatisplus.annotation.TableField; | |||||
import com.baomidou.mybatisplus.annotation.TableName; | |||||
import com.iformall.domain.po.base.TenantEntity; | |||||
import lombok.Data; | |||||
import lombok.EqualsAndHashCode; | |||||
import lombok.ToString; | |||||
import java.math.BigDecimal; | |||||
import java.util.Date; | |||||
@Data | |||||
@ToString(callSuper = true) | |||||
@EqualsAndHashCode(callSuper = true) | |||||
public class BusinessCircleBase extends TenantEntity { | |||||
protected Long id; | |||||
@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知Id",name="noticeId") | |||||
private String noticeId; | |||||
@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知创建时间",name="noticeCreateTime") | |||||
private Date noticeCreateTime; | |||||
@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知类型:MALL_TRANSACTION.SUCCESS",name="noticeEventType") | |||||
private String noticeEventType; | |||||
@Excel(name = "通知时间", width = 20, orderNum = "12") | |||||
@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知回调摘要",name="summary") | |||||
private String summary; | |||||
@Excel(name = "交易时间", width = 20, orderNum = "4", format = "yyyy-MM-dd HH:mm:ss") | |||||
@io.swagger.annotations.ApiModelProperty(value="交易完成时间",name="timeEnd") | |||||
private Date timeEnd; | |||||
@io.swagger.annotations.ApiModelProperty(value="用户实际消费金额,单位(分)",name="amount") | |||||
private Integer amount; | |||||
@TableField(exist = false) | |||||
@io.swagger.annotations.ApiModelProperty(value="用户实际消费金额,单位(元)",name="amountStr") | |||||
private String amountStr; | |||||
public String getAmountStr() { | |||||
return amount != null ? new BigDecimal(amount).divide(new BigDecimal(100)).toPlainString(): amountStr; | |||||
} | |||||
@io.swagger.annotations.ApiModelProperty(value="用户实际付款金额,单位(分)",name="payAmount") | |||||
private Integer payAmount; | |||||
@Excel(name = "付款金额(元)", width = 20, orderNum = "5") | |||||
@TableField(exist = false) | |||||
@io.swagger.annotations.ApiModelProperty(value="用户实际付款金额,单位(元)",name="payAmountStr") | |||||
private String payAmountStr; | |||||
public String getPayAmountStr() { | |||||
return payAmount != null ? new BigDecimal(payAmount).divide(new BigDecimal(100)).toPlainString(): payAmountStr; | |||||
} | |||||
@Excel(name = "支付订单号", width = 20, orderNum = "3") | |||||
@io.swagger.annotations.ApiModelProperty(value="支付订单号",name="transactionId") | |||||
private String transactionId; | |||||
@Excel(name = "通知时间", width = 20, orderNum = "11", format = "yyyy-MM-dd HH:mm:ss") | |||||
@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") | |||||
private Date createTime; | |||||
@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime") | |||||
private Date updateTime; | |||||
@io.swagger.annotations.ApiModelProperty(value="门店Id,与第三方对齐",name="merchantId") | |||||
private Long merchantId; | |||||
@Excel(name = "门店名称", width = 20, orderNum = "2") | |||||
private String merchantName; | |||||
@TableField(exist = false) | |||||
private WxMerchant merchant; | |||||
@Excel(name = "会员ID", width = 20, orderNum = "9") | |||||
@TableField(exist = false) | |||||
private String userIdStr; | |||||
public String getUserIdStr(){ | |||||
return cUserId == null?"":Long.toString(cUserId); | |||||
} | |||||
@io.swagger.annotations.ApiModelProperty(value="c端会员id,与第三方对齐",name="cUserId") | |||||
private Long cUserId; | |||||
private String cUserNickName; | |||||
@Excel(name = "会员手机号", width = 20, orderNum = "10") | |||||
@TableField(exist = false) | |||||
private String userPhoneStr; | |||||
public String getUserPhoneStr(){ | |||||
return cUserPhone; | |||||
} | |||||
private String cUserPhone; | |||||
@TableField(exist = false) | |||||
private WxCUserBasicInfo basicInfo; | |||||
@Excel(name = "积分是否变动", width = 20, orderNum = "13", replace = {"是_1", "否_0"}) | |||||
@io.swagger.annotations.ApiModelProperty(value="是否获得积分(1:是,0:否)",name="earnPoints") | |||||
private Integer earnPoints; | |||||
@Excel(name = "积分变动值", width = 20, orderNum = "14") | |||||
@io.swagger.annotations.ApiModelProperty(value="订单更新积分值",name="increasedPoints") | |||||
private Integer increasedPoints; | |||||
@Excel(name = "积分更新时间", width = 20, orderNum = "15", format = "yyyy-MM-dd HH:mm:ss") | |||||
@io.swagger.annotations.ApiModelProperty(value="积分更新时间(新增)",name="pointsUpdateTime") | |||||
private Date pointsUpdateTime; | |||||
@Excel(name = "是否退款", width = 20, orderNum = "6", replace = {"退款订单_1", "付款订单_0"}) | |||||
@io.swagger.annotations.ApiModelProperty(value="是否退款(1:是,0:否)",name="isRefund") | |||||
private Integer isRefund; | |||||
@io.swagger.annotations.ApiModelProperty(value="正常订单状态(is_refund=0时)1:部分退款2:订单关闭",name="orderStatus") | |||||
private Integer orderStatus; | |||||
@Excel(name = "退款订单号", width = 20, orderNum = "7") | |||||
@io.swagger.annotations.ApiModelProperty(value="微信支付退款单号",name="refundId") | |||||
private String refundId; | |||||
@TableField(exist = false) | |||||
@io.swagger.annotations.ApiModelProperty(value="查询-开始时间",name="startdate") | |||||
private Date startTime; | |||||
@TableField(exist = false) | |||||
@io.swagger.annotations.ApiModelProperty(value="查询-结束时间",name="enddate") | |||||
private Date endTime; | |||||
@io.swagger.annotations.ApiModelProperty(value="用户退款金额,单位(分)",name="refundAmount") | |||||
private Integer refundAmount; | |||||
@Excel(name = "退款金额(元)", width = 20, orderNum = "8") | |||||
@TableField(exist = false) | |||||
@io.swagger.annotations.ApiModelProperty(value="用户退款金额,单位(元)",name="refundAmountStr") | |||||
private String refundAmountStr; | |||||
public String getRefundAmountStr() { | |||||
return refundAmount != null ? new BigDecimal(refundAmount).divide(new BigDecimal(100)).toPlainString(): refundAmountStr; | |||||
} | |||||
} |
@@ -1,40 +0,0 @@ | |||||
package com.iformall.domain.po; | |||||
import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
import com.baomidou.mybatisplus.annotation.TableName; | |||||
import lombok.Data; | |||||
import lombok.EqualsAndHashCode; | |||||
import lombok.ToString; | |||||
@TableName(value = "wx_business_circle_order") | |||||
@Data | |||||
@ToString(callSuper = true) | |||||
@EqualsAndHashCode(callSuper = true) | |||||
public class WxBusinessCircleOrder extends BusinessCircleBase { | |||||
@io.swagger.annotations.ApiModelProperty(value="微信支付分配的商户号",name="wxMchid") | |||||
private String wxMchid; | |||||
@io.swagger.annotations.ApiModelProperty(value="商圈商户名称",name="wxMerchantName") | |||||
private String wxMerchantName; | |||||
@io.swagger.annotations.ApiModelProperty(value="门店名称,商圈在商圈小程序上圈店时填写的门店名称",name="wxShopName") | |||||
private String wxShopName; | |||||
@Excel(name = "门店编码", width = 20, orderNum = "1") | |||||
@io.swagger.annotations.ApiModelProperty(value="门店编号,商圈在商圈小程序上圈店时填写的门店编号,用于跟商圈自身已有的商户识别码对齐",name="wxShopNumber") | |||||
private String wxShopNumber; | |||||
@io.swagger.annotations.ApiModelProperty(value="小程序appid",name="appid") | |||||
private String appid; | |||||
@io.swagger.annotations.ApiModelProperty(value="openid",name="openid") | |||||
private String openid; | |||||
@io.swagger.annotations.ApiModelProperty(value="手动提交积分标记,自动提交时无该字段,用于区分用户手动申请后推送的积分",name="commitTag") | |||||
private String commitTag; | |||||
@io.swagger.annotations.ApiModelProperty(value="是否积分同步(1:是,0:否)",name="isPointsNotify") | |||||
private Integer isPointsNotify; | |||||
} |
@@ -1,39 +0,0 @@ | |||||
package com.iformall.domain.po; | |||||
import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
import com.baomidou.mybatisplus.annotation.TableField; | |||||
import com.baomidou.mybatisplus.annotation.TableName; | |||||
import lombok.Data; | |||||
import lombok.EqualsAndHashCode; | |||||
import lombok.ToString; | |||||
@TableName(value = "wx_third_party_orders") | |||||
@Data | |||||
@ToString(callSuper = true) | |||||
@EqualsAndHashCode(callSuper = true) | |||||
public class WxThirdPartyOrders extends BusinessCircleBase { | |||||
@io.swagger.annotations.ApiModelProperty(value="来源(wx_third_party_api)",name="sourceAppId") | |||||
private String sourceAppId; | |||||
@TableField(exist = false) | |||||
@io.swagger.annotations.ApiModelProperty(value="来源(wx_third_party_api)",name="sourceAppName") | |||||
private String sourceAppName; | |||||
@io.swagger.annotations.ApiModelProperty(value="1:RMB订单;2:积分订单",name="sourceType") | |||||
private Integer sourceType; | |||||
@io.swagger.annotations.ApiModelProperty(value="门店名称",name="shopName") | |||||
private String shopName; | |||||
@Excel(name = "门店编码", width = 20, orderNum = "1") | |||||
@io.swagger.annotations.ApiModelProperty(value="门店编号",name="shopNumber") | |||||
private String shopNumber; | |||||
@io.swagger.annotations.ApiModelProperty(value="顾客手机号",name="userPhone") | |||||
private String userPhone; | |||||
@io.swagger.annotations.ApiModelProperty(value="顾客编号",name="userNumber") | |||||
private String userNumber; | |||||
} |
@@ -1,20 +0,0 @@ | |||||
package com.iformall.domain.po.msg; | |||||
import lombok.Data; | |||||
import lombok.EqualsAndHashCode; | |||||
import lombok.ToString; | |||||
/** | |||||
* | |||||
*/ | |||||
@Data | |||||
@ToString(callSuper = true) | |||||
@EqualsAndHashCode(callSuper = true) | |||||
public class AfterBusinessCreditMsg extends BaseMsg { | |||||
private static final long serialVersionUID = -1l; | |||||
@io.swagger.annotations.ApiModelProperty(value="商圈订单ID",name="businessCircleOrderId") | |||||
private Long businessCircleOrderId; | |||||
} |
@@ -1,32 +0,0 @@ | |||||
package com.iformall.domain.po.msg; | |||||
import lombok.Data; | |||||
import lombok.EqualsAndHashCode; | |||||
import lombok.ToString; | |||||
@Data | |||||
@ToString(callSuper = true) | |||||
@EqualsAndHashCode(callSuper = true) | |||||
public class FmInsideThirdPartyOrdersMsg extends BaseMsg{ | |||||
private static final long serialVersionUID = 1L; | |||||
@io.swagger.annotations.ApiModelProperty(value="第三方交易状态",name="eventType") | |||||
private String eventType; | |||||
@io.swagger.annotations.ApiModelProperty(value="商圈订单Id",name="businessCircleOrderId") | |||||
private Long businessCircleOrderId; | |||||
@io.swagger.annotations.ApiModelProperty(value="门店Id",name="merchantId") | |||||
private Long merchantId; | |||||
@io.swagger.annotations.ApiModelProperty(value="c端会员id",name="cUserId") | |||||
private Long cUserId; | |||||
@io.swagger.annotations.ApiModelProperty(value="门店名称,商圈在商圈小程序上圈店时填写的门店名称",name="wxShopName") | |||||
private String wxShopName; | |||||
@io.swagger.annotations.ApiModelProperty(value="用户实际消费金额,单位(分)",name="amount") | |||||
private Integer amount; | |||||
} |
@@ -1,162 +0,0 @@ | |||||
package com.iformall.domain.vo; | |||||
import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
import com.baomidou.mybatisplus.annotation.TableField; | |||||
import com.baomidou.mybatisplus.annotation.TableName; | |||||
import com.iformall.domain.po.BusinessCircleBase; | |||||
import com.iformall.domain.po.WxCUserBasicInfo; | |||||
import com.iformall.domain.po.WxMerchant; | |||||
import com.iformall.domain.po.base.TenantEntity; | |||||
import lombok.Data; | |||||
import lombok.EqualsAndHashCode; | |||||
import lombok.ToString; | |||||
import java.math.BigDecimal; | |||||
import java.util.Date; | |||||
@Data | |||||
@ToString(callSuper = true) | |||||
@EqualsAndHashCode(callSuper = true) | |||||
public class WxThirdPartyOrdersVo extends TenantEntity { | |||||
protected Long id; | |||||
@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知Id",name="noticeId") | |||||
private String noticeId; | |||||
@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知创建时间",name="noticeCreateTime") | |||||
private Date noticeCreateTime; | |||||
@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知类型:MALL_TRANSACTION.SUCCESS",name="noticeEventType") | |||||
private String noticeEventType; | |||||
@Excel(name = "摘要", width = 20, orderNum = "10") | |||||
@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知回调摘要",name="summary") | |||||
private String summary; | |||||
@Excel(name = "抵扣/退款时间", width = 20, orderNum = "6", format = "yyyy-MM-dd HH:mm:ss") | |||||
@io.swagger.annotations.ApiModelProperty(value="交易完成时间",name="timeEnd") | |||||
private Date timeEnd; | |||||
@io.swagger.annotations.ApiModelProperty(value="用户实际消费金额,单位(分)",name="amount") | |||||
private Integer amount; | |||||
@TableField(exist = false) | |||||
@io.swagger.annotations.ApiModelProperty(value="用户实际消费金额,单位(元)",name="amountStr") | |||||
private String amountStr; | |||||
public String getAmountStr() { | |||||
return amount != null ? new BigDecimal(amount).divide(new BigDecimal(100)).toPlainString(): amountStr; | |||||
} | |||||
@Excel(name = "积分数量", width = 20, orderNum = "7") | |||||
@io.swagger.annotations.ApiModelProperty(value="用户实际付款金额,单位(分)",name="payAmount") | |||||
private Integer payAmount; | |||||
@TableField(exist = false) | |||||
@io.swagger.annotations.ApiModelProperty(value="用户实际付款金额,单位(元)",name="payAmountStr") | |||||
private String payAmountStr; | |||||
public String getPayAmountStr() { | |||||
return payAmount != null ? new BigDecimal(payAmount).divide(new BigDecimal(100)).toPlainString(): payAmountStr; | |||||
} | |||||
@Excel(name = "付款订单编号", width = 20, orderNum = "3") | |||||
@io.swagger.annotations.ApiModelProperty(value="支付订单号",name="transactionId") | |||||
private String transactionId; | |||||
@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") | |||||
private Date createTime; | |||||
@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime") | |||||
private Date updateTime; | |||||
@io.swagger.annotations.ApiModelProperty(value="门店Id,与第三方对齐",name="merchantId") | |||||
private Long merchantId; | |||||
@Excel(name = "门店名称", width = 20, orderNum = "2") | |||||
private String merchantName; | |||||
@TableField(exist = false) | |||||
private WxMerchant merchant; | |||||
@Excel(name = "会员ID", width = 20, orderNum = "8") | |||||
@TableField(exist = false) | |||||
private String userIdStr; | |||||
public String getUserIdStr(){ | |||||
return cUserId == null?"":Long.toString(cUserId); | |||||
} | |||||
@io.swagger.annotations.ApiModelProperty(value="c端会员id,与第三方对齐",name="cUserId") | |||||
private Long cUserId; | |||||
private String cUserNickName; | |||||
@Excel(name = "会员手机号", width = 20, orderNum = "9") | |||||
@TableField(exist = false) | |||||
private String userPhoneStr; | |||||
public String getUserPhoneStr(){ | |||||
return cUserPhone; | |||||
} | |||||
private String cUserPhone; | |||||
@TableField(exist = false) | |||||
private WxCUserBasicInfo basicInfo; | |||||
@io.swagger.annotations.ApiModelProperty(value="是否获得积分(1:是,0:否)",name="earnPoints") | |||||
private Integer earnPoints; | |||||
@io.swagger.annotations.ApiModelProperty(value="订单更新积分值",name="increasedPoints") | |||||
private Integer increasedPoints; | |||||
@io.swagger.annotations.ApiModelProperty(value="积分更新时间(新增)",name="increasedPoints") | |||||
private Date pointsUpdateTime; | |||||
@Excel(name = "是否退款", width = 20, orderNum = "4", replace = {"退款订单_1", "付款订单_0"}) | |||||
@io.swagger.annotations.ApiModelProperty(value="是否退款(1:是,0:否)",name="isRefund") | |||||
private Integer isRefund; | |||||
@io.swagger.annotations.ApiModelProperty(value="正常订单状态(is_refund=0时)1:部分退款2:订单关闭",name="orderStatus") | |||||
private Integer orderStatus; | |||||
@Excel(name = "退款订单编号", width = 20, orderNum = "5") | |||||
@io.swagger.annotations.ApiModelProperty(value="微信支付退款单号",name="refundId") | |||||
private String refundId; | |||||
@TableField(exist = false) | |||||
@io.swagger.annotations.ApiModelProperty(value="查询-开始时间",name="startdate") | |||||
private Date startTime; | |||||
@TableField(exist = false) | |||||
@io.swagger.annotations.ApiModelProperty(value="查询-结束时间",name="enddate") | |||||
private Date endTime; | |||||
@io.swagger.annotations.ApiModelProperty(value="用户退款金额,单位(分)",name="refundAmount") | |||||
private Integer refundAmount; | |||||
@TableField(exist = false) | |||||
@io.swagger.annotations.ApiModelProperty(value="用户退款金额,单位(元)",name="refundAmountStr") | |||||
private String refundAmountStr; | |||||
public String getRefundAmountStr() { | |||||
return refundAmount != null ? new BigDecimal(refundAmount).divide(new BigDecimal(100)).toPlainString(): refundAmountStr; | |||||
} | |||||
@io.swagger.annotations.ApiModelProperty(value="来源(wx_third_party_api)",name="sourceAppId") | |||||
private String sourceAppId; | |||||
@TableField(exist = false) | |||||
@io.swagger.annotations.ApiModelProperty(value="来源(wx_third_party_api)",name="sourceAppName") | |||||
private String sourceAppName; | |||||
@io.swagger.annotations.ApiModelProperty(value="1:RMB订单;2:积分订单",name="sourceType") | |||||
private Integer sourceType; | |||||
@io.swagger.annotations.ApiModelProperty(value="门店名称",name="shopName") | |||||
private String shopName; | |||||
@Excel(name = "门店编码", width = 20, orderNum = "1") | |||||
@io.swagger.annotations.ApiModelProperty(value="门店编号",name="shopNumber") | |||||
private String shopNumber; | |||||
@io.swagger.annotations.ApiModelProperty(value="顾客手机号",name="userPhone") | |||||
private String userPhone; | |||||
@io.swagger.annotations.ApiModelProperty(value="顾客编号",name="userNumber") | |||||
private String userNumber; | |||||
} |
@@ -1,48 +0,0 @@ | |||||
package com.iformall.enums; | |||||
/** | |||||
* . | |||||
*/ | |||||
public enum EnumBusinessCircleAuthorizeState { | |||||
//UNAUTHORIZED:未授权 | |||||
//AUTHORIZED:已授权 | |||||
//DEAUTHORIZED:已取消授权 | |||||
UNAUTHORIZED(0, "UNAUTHORIZED"), | |||||
AUTHORIZED(1, "AUTHORIZED"), | |||||
DEAUTHORIZED(2, "DEAUTHORIZED"), | |||||
; | |||||
public static EnumBusinessCircleAuthorizeState getEnum(Integer code) { | |||||
for (EnumBusinessCircleAuthorizeState value : values()) { | |||||
if (value.getCode().equals(code)) { | |||||
return value; | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
public static EnumBusinessCircleAuthorizeState getEnum(String message) { | |||||
for (EnumBusinessCircleAuthorizeState value : values()) { | |||||
if (value.getMessage().equals(message)) { | |||||
return value; | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
private Integer code; | |||||
private String message; | |||||
EnumBusinessCircleAuthorizeState(Integer code, String message) { | |||||
this.code = code; | |||||
this.message = message; | |||||
} | |||||
public Integer getCode() { | |||||
return code; | |||||
} | |||||
public String getMessage() { | |||||
return message; | |||||
} | |||||
} |
@@ -1,50 +0,0 @@ | |||||
package com.iformall.mapper; | |||||
import com.iformall.common.CommonMapper; | |||||
import com.iformall.domain.po.AliBusinessCircleOrder; | |||||
import com.iformall.domain.po.BusinessCircleBase; | |||||
import org.apache.ibatis.annotations.Param; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
public interface AliBusinessCircleOrderMapper extends CommonMapper<AliBusinessCircleOrder, Long> { | |||||
List<AliBusinessCircleOrder> findList(AliBusinessCircleOrder record); | |||||
AliBusinessCircleOrder getById(AliBusinessCircleOrder record); | |||||
AliBusinessCircleOrder getOrderByTransactionId(AliBusinessCircleOrder record); | |||||
AliBusinessCircleOrder getRefundOrderByRefundId(AliBusinessCircleOrder record); | |||||
List<AliBusinessCircleOrder> getRefundOrderByTransactionId(AliBusinessCircleOrder record); | |||||
/** | |||||
* 成功通知新建 | |||||
* @param record | |||||
*/ | |||||
void insertNoticeOrder(AliBusinessCircleOrder record); | |||||
/** | |||||
* 加积分 | |||||
* @param record | |||||
*/ | |||||
void updatePoints(AliBusinessCircleOrder record); | |||||
/** | |||||
* 退款 | |||||
* @param record | |||||
*/ | |||||
void insertRefundNoticeOrder(AliBusinessCircleOrder record); | |||||
/** | |||||
* 修改正常订单状态 | |||||
* @param record | |||||
*/ | |||||
void updateOrderStatus(AliBusinessCircleOrder record); | |||||
Integer sumCirclePayment(BusinessCircleBase record); | |||||
Integer sumCircleRefundAmount(BusinessCircleBase circleOrder); | |||||
} |
@@ -1,12 +1,8 @@ | |||||
package com.iformall.mapper; | package com.iformall.mapper; | ||||
import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
import com.iformall.domain.po.AliBusinessCircleOrder; | |||||
import com.iformall.domain.po.sm.InviteCode; | import com.iformall.domain.po.sm.InviteCode; | ||||
import com.iformall.service.sm.InviteCodeService; | |||||
import org.apache.ibatis.annotations.Param; | import org.apache.ibatis.annotations.Param; | ||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
public interface InviteCodeMapper extends CommonMapper<InviteCode, Long> { | public interface InviteCodeMapper extends CommonMapper<InviteCode, Long> { | ||||
@@ -1,53 +0,0 @@ | |||||
package com.iformall.mapper; | |||||
import com.iformall.common.CommonMapper; | |||||
import com.iformall.domain.po.BusinessCircleBase; | |||||
import com.iformall.domain.po.WxBusinessCircleOrder; | |||||
import org.apache.ibatis.annotations.Param; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
public interface WxBusinessCircleOrderMapper extends CommonMapper<WxBusinessCircleOrder, Long> { | |||||
List<WxBusinessCircleOrder> findList(WxBusinessCircleOrder record); | |||||
WxBusinessCircleOrder getById(WxBusinessCircleOrder record); | |||||
WxBusinessCircleOrder getOrderByTransactionId(WxBusinessCircleOrder record); | |||||
WxBusinessCircleOrder getRefundOrderByRefundId(WxBusinessCircleOrder record); | |||||
List<WxBusinessCircleOrder> getRefundOrderByTransactionId(WxBusinessCircleOrder record); | |||||
/** | |||||
* 成功通知新建 | |||||
* @param record | |||||
*/ | |||||
void insertNoticeOrder(WxBusinessCircleOrder record); | |||||
/** | |||||
* 加积分 | |||||
* @param record | |||||
*/ | |||||
void updatePoints(WxBusinessCircleOrder record); | |||||
/** | |||||
* 积分同步状态修改 | |||||
*/ | |||||
void updateIsPointsNotify(WxBusinessCircleOrder record); | |||||
/** | |||||
* 退款通知新建 | |||||
* @param record | |||||
*/ | |||||
void insertRefundNoticeOrder(WxBusinessCircleOrder record); | |||||
/** | |||||
* 修改正常订单状态 | |||||
* @param record | |||||
*/ | |||||
void updateOrderStatus(WxBusinessCircleOrder record); | |||||
Integer sumCirclePayment(BusinessCircleBase record); | |||||
Integer sumCircleRefundAmount(BusinessCircleBase circleOrder); | |||||
} |
@@ -1,51 +0,0 @@ | |||||
package com.iformall.mapper; | |||||
import com.iformall.common.CommonMapper; | |||||
import com.iformall.domain.po.BusinessCircleBase; | |||||
import com.iformall.domain.po.WxThirdPartyOrders; | |||||
import com.iformall.domain.vo.WxThirdPartyOrdersVo; | |||||
import java.util.List; | |||||
public interface WxThirdPartyOrdersMapper extends CommonMapper<WxThirdPartyOrders, Long> { | |||||
List<WxThirdPartyOrders> findList(WxThirdPartyOrders record); | |||||
List<WxThirdPartyOrdersVo> findListVo(WxThirdPartyOrders circleOrder); | |||||
WxThirdPartyOrders getById(WxThirdPartyOrders record); | |||||
WxThirdPartyOrders getOrderByTransactionId(WxThirdPartyOrders record); | |||||
WxThirdPartyOrders getRefundOrderByRefundId(WxThirdPartyOrders record); | |||||
List<WxThirdPartyOrders> getRefundOrderByTransactionId(WxThirdPartyOrders record); | |||||
/** | |||||
* 成功通知新建 | |||||
* @param record | |||||
*/ | |||||
void insertNoticeOrder(WxThirdPartyOrders record); | |||||
/** | |||||
* 加积分 | |||||
* @param record | |||||
*/ | |||||
void updatePoints(WxThirdPartyOrders record); | |||||
/** | |||||
* 退款 | |||||
* @param record | |||||
*/ | |||||
void insertRefundNoticeOrder(WxThirdPartyOrders record); | |||||
/** | |||||
* 修改正常订单状态 | |||||
* @param record | |||||
*/ | |||||
void updateOrderStatus(WxThirdPartyOrders record); | |||||
Integer sumCirclePayment(BusinessCircleBase record); | |||||
Integer sumCircleRefundAmount(BusinessCircleBase circleOrder); | |||||
} |
@@ -1,60 +0,0 @@ | |||||
package com.iformall.service; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.domain.po.AliBusinessCircleOrder; | |||||
import com.iformall.domain.po.BusinessCircleBase; | |||||
import com.iformall.domain.po.WxMerchant; | |||||
import com.iformall.domain.po.base.TenantEntity; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.util.List; | |||||
public interface AliBusinessCircleOrderService { | |||||
/** | |||||
* 根据实体查询分页列表 | |||||
* | |||||
* @param record | |||||
* @param pageIndex | |||||
* @param pageSize | |||||
* @return | |||||
*/ | |||||
PageInfo<AliBusinessCircleOrder> listAsPage(AliBusinessCircleOrder record, Integer pageIndex, Integer pageSize); | |||||
/** | |||||
* id+tenantId | |||||
* @param | |||||
* @return | |||||
*/ | |||||
AliBusinessCircleOrder getById(Long id, String tenantId); | |||||
AliBusinessCircleOrder detail(Long id, TenantEntity tenantInfo); | |||||
/** | |||||
* transactionId+tenantId | |||||
* @param | |||||
* @return | |||||
*/ | |||||
AliBusinessCircleOrder getOrderByTransactionId(String transactionId, String tenantId); | |||||
AliBusinessCircleOrder getRefundOrderByRefundId(String refundId, String tenantId); | |||||
List<AliBusinessCircleOrder> getRefundOrderByTransactionId(String transactionId, String tenantId); | |||||
ResultData createOrder(WxMerchant wxMerchant, AliBusinessCircleOrder record); | |||||
ResultData insertRefundNoticeOrder(WxMerchant wxMerchant, AliBusinessCircleOrder record); | |||||
/** | |||||
* 积分 | |||||
* @param record | |||||
*/ | |||||
void updatePoints(AliBusinessCircleOrder record); | |||||
void exportData(AliBusinessCircleOrder circleOrder, HttpServletRequest request, HttpServletResponse response); | |||||
Integer sumCirclePayment(BusinessCircleBase circleOrder); | |||||
Integer sumCircleRefundAmount(BusinessCircleBase circleOrder); | |||||
} |
@@ -1,92 +0,0 @@ | |||||
package com.iformall.service; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.domain.po.BusinessCircleBase; | |||||
import com.iformall.domain.po.WxBusinessCircleOrder; | |||||
import com.iformall.domain.po.base.TenantEntity; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
public interface WxBusinessCircleOrderService { | |||||
/** | |||||
* 根据实体查询分页列表 | |||||
* | |||||
* @param record | |||||
* @param pageIndex | |||||
* @param pageSize | |||||
* @return | |||||
*/ | |||||
PageInfo<WxBusinessCircleOrder> listAsPage(WxBusinessCircleOrder record, Integer pageIndex, Integer pageSize); | |||||
/** | |||||
* id+tenantId | |||||
* @param | |||||
* @return | |||||
*/ | |||||
WxBusinessCircleOrder getById(Long id, String tenantId); | |||||
WxBusinessCircleOrder detail(Long id, TenantEntity tenantInfo); | |||||
/** | |||||
* transactionId+tenantId | |||||
* @param | |||||
* @return | |||||
*/ | |||||
WxBusinessCircleOrder getOrderByTransactionId(String transactionId, String tenantId); | |||||
WxBusinessCircleOrder getRefundOrderByRefundId(String refundId, String tenantId); | |||||
List<WxBusinessCircleOrder> getRefundOrderByTransactionId(String transactionId, String tenantId); | |||||
ResultData createOrder(WxBusinessCircleOrder record); | |||||
ResultData insertRefundNoticeOrder(WxBusinessCircleOrder record); | |||||
/** | |||||
* 更新积分 | |||||
* @param record | |||||
*/ | |||||
void updatePoints(WxBusinessCircleOrder record); | |||||
/** | |||||
* 同步积分状态 | |||||
* @param record | |||||
*/ | |||||
void notifyPoints(WxBusinessCircleOrder record); | |||||
/** | |||||
* 积分同步状态修改 | |||||
*/ | |||||
void updateIsPointsNotify(WxBusinessCircleOrder record); | |||||
void sendsyncNotifyPointsMsg(TenantEntity tenantEntity, Long businessCircleOrderId); | |||||
void exportData(WxBusinessCircleOrder circleOrder, HttpServletRequest request, HttpServletResponse response); | |||||
Integer sumCirclePayment(BusinessCircleBase circleOrder); | |||||
Integer sumCircleRefundAmount(BusinessCircleBase circleOrder); | |||||
/** | |||||
* 同步授权快速积分 | |||||
*/ | |||||
ResultData syncauthorizeState(TenantEntity tenantEntity,String openid); | |||||
/** | |||||
* 查询待积分状态 | |||||
*/ | |||||
ResultData getPointsCommitStatus(TenantEntity tenantEntity,String openId); | |||||
/** | |||||
* 商圈同步停车状态 | |||||
* state | |||||
* IN:入场,用户开车进入商圈 | |||||
* OUT:离场,用户开车离开商圈 | |||||
*/ | |||||
ResultData syncParkings(TenantEntity tenantEntity,String openId,String plate_number,String state,Date time); | |||||
void sendSyncParkingsMsg(TenantEntity tenantEntity,Long carCmdLogId); | |||||
} |
@@ -1,50 +0,0 @@ | |||||
package com.iformall.service; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.domain.po.WxMemberCard; | |||||
import com.iformall.domain.po.base.TenantEntity; | |||||
public interface WxMemberCardService { | |||||
/** | |||||
* 根据实体查询分页列表 | |||||
* | |||||
* @param record | |||||
* @param pageIndex | |||||
* @param pageSize | |||||
* @return | |||||
*/ | |||||
PageInfo<WxMemberCard> listAsPage(WxMemberCard record, Integer pageIndex, Integer pageSize); | |||||
ResultData saveorupdate(WxMemberCard record); | |||||
ResultData saveorupdateByCode(WxMemberCard record); | |||||
ResultData delUserCardStatusByCode(WxMemberCard record); | |||||
/** | |||||
* 同步会员卡卡信息 | |||||
*/ | |||||
ResultData syncMemberCard(TenantEntity tenantEntity,String card_id,String code); | |||||
void sendSyncMemberCardMsg(TenantEntity tenantEntity,String card_id,String code); | |||||
/** | |||||
* 同步会员卡等级 | |||||
* need_inform_level 是否发送等级变更通知 | |||||
*/ | |||||
ResultData syncMemberCardLevel(TenantEntity tenantEntity,String card_id,String code,String markid, | |||||
String level,Boolean need_inform_level); | |||||
void sendsyncMemberCardLevelMsg(TenantEntity tenantEntity,Long baseUserId,Long scoreHistoryId); | |||||
/** | |||||
* 更新会员卡积分 | |||||
*/ | |||||
ResultData syncMemberCardBonus(TenantEntity tenantEntity,String card_id,String code,String markid, | |||||
int before_bonus_value,int bonus_value,Boolean need_inform_bonus); | |||||
void sendsyncMemberCardBonusMsg(TenantEntity tenantEntity,Long cuserId,Long baseUserId,Long creditHistoryId); | |||||
} |
@@ -1,74 +0,0 @@ | |||||
package com.iformall.service; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.domain.po.BusinessCircleBase; | |||||
import com.iformall.domain.po.WxThirdPartyOrders; | |||||
import com.iformall.domain.po.base.TenantEntity; | |||||
import com.iformall.enums.EnumThirdOrderType; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.util.List; | |||||
public interface WxThirdPartyOrdersService { | |||||
/** | |||||
* 根据实体查询分页列表 | |||||
* | |||||
* @param record | |||||
* @param pageIndex | |||||
* @param pageSize | |||||
* @return | |||||
*/ | |||||
PageInfo<WxThirdPartyOrders> listAsPage(WxThirdPartyOrders record, Integer pageIndex, Integer pageSize); | |||||
/** | |||||
* id+tenantId | |||||
* @param | |||||
* @return | |||||
*/ | |||||
WxThirdPartyOrders getById(Long id, String tenantId); | |||||
WxThirdPartyOrders detail(Long id, TenantEntity tenantInfo); | |||||
/** | |||||
* transactionId+tenantId | |||||
* @param | |||||
* @return | |||||
*/ | |||||
WxThirdPartyOrders getOrderByTransactionId(EnumThirdOrderType orderType, String transactionId, String tenantId); | |||||
WxThirdPartyOrders getRefundOrderByRefundId(EnumThirdOrderType orderType,String refundId, String tenantId); | |||||
List<WxThirdPartyOrders> getRefundOrderByTransactionId(EnumThirdOrderType orderType, String transactionId, String tenantId); | |||||
ResultData createOrder(WxThirdPartyOrders record); | |||||
ResultData insertRefundNoticeOrder(WxThirdPartyOrders record); | |||||
/** | |||||
* 积分 | |||||
* @param record | |||||
*/ | |||||
void updatePoints(WxThirdPartyOrders record); | |||||
/** | |||||
* 积分抵扣 | |||||
* @param record | |||||
*/ | |||||
void pointDeduction(WxThirdPartyOrders record); | |||||
void pointRefund(WxThirdPartyOrders thirdPartyOrders); | |||||
void pointChange(WxThirdPartyOrders record); | |||||
void exportData(WxThirdPartyOrders circleOrder, HttpServletRequest request, HttpServletResponse response); | |||||
void exportDataVo(WxThirdPartyOrders circleOrder, HttpServletRequest request, HttpServletResponse response); | |||||
Integer sumCirclePayment(BusinessCircleBase circleOrder); | |||||
Integer sumCircleRefundAmount(BusinessCircleBase circleOrder); | |||||
} |
@@ -1,381 +0,0 @@ | |||||
package com.iformall.service.impl; | |||||
import com.github.pagehelper.PageHelper; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.IdWorker; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.domain.po.*; | |||||
import com.iformall.domain.po.base.TenantEntity; | |||||
import com.iformall.enums.*; | |||||
import com.iformall.exception.MallinkException; | |||||
import com.iformall.mapper.AliBusinessCircleOrderMapper; | |||||
import com.iformall.service.*; | |||||
import com.iformall.utils.RedisLock; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import org.springframework.transaction.annotation.Propagation; | |||||
import org.springframework.transaction.annotation.Transactional; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
@Service | |||||
public class AliBusinessCircleOrderServiceImpl implements AliBusinessCircleOrderService { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
private static final String ALI_CIRCLE_KEY = "CIRCLE:ALI:"; | |||||
@Autowired | |||||
ExcelService excelService; | |||||
@Autowired | |||||
RedisLock redisLock; | |||||
@Autowired | |||||
AliBusinessCircleOrderMapper aliBusinessCircleOrderMapper; | |||||
@Autowired | |||||
WxMerchantService wxMerchantService; | |||||
@Autowired | |||||
AliPayCUserService aliPayCUserService; | |||||
@Autowired | |||||
WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
@Autowired | |||||
WxCreditHistoryService creditHistoryService; | |||||
@Autowired | |||||
WxCouponSendService wxCouponSendService; | |||||
@Override | |||||
public PageInfo<AliBusinessCircleOrder> listAsPage(AliBusinessCircleOrder record, Integer pageIndex, Integer pageSize) { | |||||
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> aliBusinessCircleOrderMapper.findList(record)); | |||||
} | |||||
@Override | |||||
public AliBusinessCircleOrder getById(Long id, String tenantId) { | |||||
AliBusinessCircleOrder recordQ = new AliBusinessCircleOrder(); | |||||
recordQ.setId(id); | |||||
recordQ.setTenantId(tenantId); | |||||
return aliBusinessCircleOrderMapper.getById(recordQ); | |||||
} | |||||
@Override | |||||
public AliBusinessCircleOrder detail(Long id, TenantEntity tenantInfo) { | |||||
AliBusinessCircleOrder order = this.getById(id, tenantInfo.getTenantId()); | |||||
if(order.getMerchantId() != null){ | |||||
order.setMerchant(wxMerchantService.selectById(order.getMerchantId())); | |||||
} | |||||
if(order.getCUserId() != null){ | |||||
order.setBasicInfo(wxCUserBasicInfoService.getById(id,tenantInfo.getFinalTenantId())); | |||||
} | |||||
// if(order.getIsRefund() != null && order.getIsRefund().equals(EnumYesOrNo.YES.getCode())){ | |||||
// | |||||
// } | |||||
return order; | |||||
} | |||||
@Override | |||||
public AliBusinessCircleOrder getOrderByTransactionId(String transactionId, String tenantId) { | |||||
AliBusinessCircleOrder recordQ = new AliBusinessCircleOrder(); | |||||
recordQ.setTransactionId(transactionId); | |||||
recordQ.setTenantId(tenantId); | |||||
return aliBusinessCircleOrderMapper.getOrderByTransactionId(recordQ); | |||||
} | |||||
@Override | |||||
public AliBusinessCircleOrder getRefundOrderByRefundId(String refundId, String tenantId) { | |||||
AliBusinessCircleOrder recordQ = new AliBusinessCircleOrder(); | |||||
recordQ.setRefundId(refundId); | |||||
recordQ.setTenantId(tenantId); | |||||
return aliBusinessCircleOrderMapper.getRefundOrderByRefundId(recordQ); | |||||
} | |||||
@Override | |||||
public List<AliBusinessCircleOrder> getRefundOrderByTransactionId(String transactionId, String tenantId) { | |||||
AliBusinessCircleOrder recordQ = new AliBusinessCircleOrder(); | |||||
recordQ.setTransactionId(transactionId); | |||||
recordQ.setTenantId(tenantId); | |||||
return aliBusinessCircleOrderMapper.getRefundOrderByTransactionId(recordQ); | |||||
} | |||||
@Override | |||||
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
public ResultData createOrder(WxMerchant wxMerchant, AliBusinessCircleOrder record) { | |||||
String lockKey = StringUtils.join(ALI_CIRCLE_KEY,record.getTransactionId(), ":",EnumYesOrNo.NO.getCode(),":","lock"); | |||||
long time = System.currentTimeMillis() + 2000; | |||||
String timeStr = String.valueOf(time); | |||||
if (redisLock.lock2(lockKey, timeStr)) { | |||||
AliBusinessCircleOrder byTransactionId = this.getOrderByTransactionId(record.getTransactionId(),record.getTenantId()); | |||||
if(byTransactionId != null){ | |||||
logger.error("--Ali商圈付款--订单消息已存在---byTransactionId="+byTransactionId.getTransactionId()); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
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); | |||||
if(wxMerchant == null && StringUtils.isNotBlank(record.getMallStoreId())){ | |||||
wxMerchant = wxMerchantService.getMerchantByEncode(record.getMallStoreId()); | |||||
} | |||||
if(wxMerchant != null){ | |||||
record.setMerchantId(wxMerchant.getId()); | |||||
record.setMerchantName(wxMerchant.getName()); | |||||
}else{ | |||||
logger.error("--Ali商圈付款通知消息未找到门店--mallStoreId="+record.getMallStoreId()); | |||||
record.setMerchantName("未知门店"); | |||||
} | |||||
if(record.getCUserId() != null){ | |||||
WxCUserBasicInfo byId = wxCUserBasicInfoService.getById(record.getCUserId(), record.getFinalTenantId()); | |||||
if(byId != null){ | |||||
record.setCUserNickName(byId.getNickName()); | |||||
record.setCUserPhone(byId.getPhone()); | |||||
}else{ | |||||
record.setCUserId(null); | |||||
} | |||||
}else if(record.getCUserPhone() != null) { | |||||
WxCUserBasicInfo byPhone = wxCUserBasicInfoService.registerByPhone(record, record.getCUserPhone(), null,null, null, null); | |||||
if (byPhone != null) { | |||||
record.setCUserId(byPhone.getId()); | |||||
record.setCUserNickName(byPhone.getNickName()); | |||||
record.setCUserPhone(byPhone.getPhone()); | |||||
} | |||||
}else{ | |||||
AliPayCUser userQ = new AliPayCUser(); | |||||
userQ.updateTenantInfo(record); | |||||
userQ.setAlipayUserId(record.getBuyerId()); | |||||
AliPayCUser aliUser = aliPayCUserService.getByAliPayUserId(userQ); | |||||
if(aliUser != null){ | |||||
// WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.findInfoByPhone(aliUser, aliUser.getPhone()); | |||||
WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.registerByPhone(aliUser, aliUser.getPhone(),aliUser.getName(),null,null,null); | |||||
if(infoByPhone != null ){ | |||||
record.setCUserId(infoByPhone.getId()); | |||||
record.setCUserNickName(infoByPhone.getNickName()); | |||||
record.setCUserPhone(infoByPhone.getPhone()); | |||||
}else{ | |||||
logger.error("--Ali商圈付款通知消息未找到会员--aliUserId="+record.getBuyerId()); | |||||
} | |||||
}else{ | |||||
logger.error("--Ali商圈付款通知消息未找到会员--aliUserId="+record.getBuyerId()); | |||||
} | |||||
} | |||||
aliBusinessCircleOrderMapper.insertNoticeOrder(record); | |||||
if(record.getCUserId() == null){ | |||||
redisLock.unlock(lockKey, timeStr); | |||||
return new ResultData(0); | |||||
} | |||||
try { | |||||
wxCouponSendService.sendCouponToUser(EnumCouponSendSendType.B_MICROPAY, record,EnumPayWay.PAY_WAY_NOT_UNPAY_B_MA,EnumPayVersion.NO_VERSION); | |||||
} catch (Exception e) { | |||||
logger.error("支付发券: " + e.getMessage()); | |||||
} | |||||
Integer businessId = EnumBusiness.BUSINESS_ID6.getCode(); | |||||
if(wxMerchant != null){ | |||||
businessId = wxMerchant.getBusinessId(); | |||||
} | |||||
WxCreditHistory creditHistory = new WxCreditHistory(); | |||||
creditHistory.setTenantId(record.getFinalTenantId()); | |||||
creditHistory.setOperatorType(EnumUserType.ALI_CIRCLE.getCode()); | |||||
creditHistory.setOperatorId(record.getCUserId()); | |||||
creditHistory.setCUserId(record.getCUserId()); | |||||
creditHistory.setCreateDate(now); | |||||
creditHistory.setCouponId(record.getId()); | |||||
creditHistory.setBusinessId(businessId); | |||||
creditHistory.setMerchantId(record.getMerchantId()); | |||||
creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode()); | |||||
creditHistory.setSpend(record.getPayAmount()); | |||||
creditHistory.setChangePurpose("支付宝商圈消费:商户["+record.getMerchantName()+"] ("+record.getPayAmountStr()+"元) "); | |||||
creditHistory = creditHistoryService.saveOrUpdate(creditHistory,record.getTenantId()); | |||||
Integer creditNum = 0; | |||||
if (creditHistory.getCreditNum() != null) { | |||||
creditNum = creditHistory.getCreditNum(); | |||||
} | |||||
if(creditNum == 0){ | |||||
redisLock.unlock(lockKey, timeStr); | |||||
return new ResultData(0); | |||||
} | |||||
record.setIncreasedPoints(creditNum); | |||||
record.setPointsUpdateTime(creditHistory.getCreateDate()); | |||||
this.updatePoints(record); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
return new ResultData(creditNum); | |||||
} | |||||
}else{ | |||||
logger.debug("CacheAspect 读库等待中, key:{}: " + lockKey); | |||||
try { | |||||
Thread.sleep(2000); | |||||
} catch (InterruptedException e) { | |||||
e.printStackTrace(); | |||||
}finally { | |||||
redisLock.unlock(lockKey, timeStr); | |||||
} | |||||
return new ResultData(ErrorCode.SYS_REPEAT_SUBMIT_EXCEPTION); | |||||
} | |||||
} | |||||
@Override | |||||
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
public ResultData insertRefundNoticeOrder(WxMerchant wxMerchant, AliBusinessCircleOrder record) { | |||||
AliBusinessCircleOrder order = this.getOrderByTransactionId(record.getTransactionId(),record.getTenantId()); | |||||
if(order == null){ | |||||
logger.error("--Ali商圈退款--付款消息未找到--transactionId="+record.getTransactionId()); | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "付款消息未找到"); | |||||
}else{ | |||||
String lockKey = StringUtils.join(ALI_CIRCLE_KEY,record.getTransactionId(), ":",EnumYesOrNo.YES.getCode(),":","lock"); | |||||
long time = System.currentTimeMillis() + 2000; | |||||
String timeStr = String.valueOf(time); | |||||
if (redisLock.lock2(lockKey, timeStr)) { | |||||
List<AliBusinessCircleOrder> refundOrders = this.getRefundOrderByTransactionId(record.getTransactionId(),record.getTenantId()); | |||||
if(refundOrders != null && refundOrders.size() > 0){ | |||||
logger.error("--Ali商圈退款--已经退款--transactionId="+record.getTransactionId()); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "退款数据已存在"); | |||||
} | |||||
// AliBusinessCircleOrder refundOrder = this.getRefundOrderByRefundId(record.getRefundId(),record.getTenantId()); | |||||
// if(refundOrder != null){ | |||||
// logger.error("--Ali商圈退款--退款消息已存在---RefundId="+record.getRefundId()); | |||||
// }else{ | |||||
// List<AliBusinessCircleOrder> refundOrders = this.getRefundOrderByTransactionId(record.getTransactionId(),record.getTenantId()); | |||||
// Integer amount = order.getPayAmount(); | |||||
// Integer increasedPoints = order.getIncreasedPoints(); | |||||
// Integer refundAmount = 0; | |||||
// Integer refundIncreasedPoints = 0; | |||||
// | |||||
// if(refundOrders != null && refundOrders.size()>0){ | |||||
// for (AliBusinessCircleOrder ro:refundOrders) { | |||||
// refundAmount += ro.getRefundAmount(); | |||||
// refundIncreasedPoints += ro.getIncreasedPoints(); | |||||
// } | |||||
// } | |||||
// if(refundAmount >= amount){ | |||||
// logger.error("--Ali商圈退款--已经退款--transactionId="+record.getTransactionId()); | |||||
// }else if((refundAmount + record.getRefundAmount()) > amount ){ | |||||
// logger.error("--Ali商圈退款--退款金额超限--transactionId="+record.getTransactionId()); | |||||
// } | |||||
else{ | |||||
Date now = new Date(); | |||||
final IdWorker idWorker = IdWorker.get(); | |||||
record.setId(idWorker.nextId()); | |||||
record.setCreateTime(now); | |||||
record.setUpdateTime(now); | |||||
record.setAmount(order.getAmount()); | |||||
record.setPayAmount(order.getPayAmount()); | |||||
if(record.getRefundAmount() == null){ | |||||
record.setRefundAmount(order.getPayAmount()); | |||||
} | |||||
record.setCUserId(order.getCUserId()); | |||||
record.setCUserNickName(order.getCUserNickName()); | |||||
record.setCUserPhone(order.getCUserPhone()); | |||||
record.setMerchantId(order.getMerchantId()); | |||||
record.setMerchantName(order.getMerchantName()); | |||||
aliBusinessCircleOrderMapper.insertRefundNoticeOrder(record); | |||||
order.setOrderStatus(2);//全额退款 订单关闭 | |||||
order.setUpdateTime(now); | |||||
aliBusinessCircleOrderMapper.updateOrderStatus(order); | |||||
int creditNum = 0; | |||||
if(order.getEarnPoints().equals(EnumYesOrNo.YES.getCode())){ | |||||
WxCreditHistory creditHistory = new WxCreditHistory(); | |||||
creditHistory.setTenantId(record.getFinalTenantId()); | |||||
creditHistory.setOperatorType(EnumUserType.ALI_CIRCLE.getCode()); | |||||
creditHistory.setOperatorId(record.getCUserId()); | |||||
creditHistory.setCUserId(record.getCUserId()); | |||||
creditHistory.setCreateDate(new Date()); | |||||
creditHistory.setCouponId(record.getId()); | |||||
creditHistory.setMerchantId(order.getMerchantId()); | |||||
creditHistory.setCreditType(EnumScoreType.REFUND_CONSUMPTION.getCode()); | |||||
// int points = 0; | |||||
// if((refundAmount + record.getRefundAmount()) == amount){ | |||||
// points = increasedPoints - refundIncreasedPoints; | |||||
// }else{ | |||||
// points = new BigDecimal(order.getIncreasedPoints()) | |||||
// .divide(new BigDecimal(order.getPayAmount()),2,BigDecimal.ROUND_HALF_UP) | |||||
// .multiply(new BigDecimal(record.getRefundAmount())) | |||||
// .intValue(); | |||||
// } | |||||
int points = order.getIncreasedPoints(); | |||||
creditHistory.setCreditNum(points); | |||||
creditHistory.setSpend(0-record.getRefundAmount()); | |||||
creditHistory.setChangePurpose("支付宝商圈退款:商户["+record.getMerchantName()+"] ("+record.getRefundAmountStr()+"元) "); | |||||
creditHistory = creditHistoryService.saveOrUpdate(creditHistory,record.getTenantId()); | |||||
if (creditHistory.getCreditNum() != null) { | |||||
creditNum = creditHistory.getCreditNum(); | |||||
} | |||||
if(creditNum != 0){ | |||||
record.setIncreasedPoints(creditNum); | |||||
record.setPointsUpdateTime(creditHistory.getCreateDate()); | |||||
this.updatePoints(record); | |||||
} | |||||
} | |||||
redisLock.unlock(lockKey, timeStr); | |||||
return new ResultData(creditNum); | |||||
} | |||||
// } | |||||
}else{ | |||||
logger.debug("CacheAspect 读库等待中, key:{}: " + lockKey); | |||||
try { | |||||
Thread.sleep(2000); | |||||
} catch (InterruptedException e) { | |||||
e.printStackTrace(); | |||||
}finally { | |||||
redisLock.unlock(lockKey, timeStr); | |||||
} | |||||
return new ResultData(ErrorCode.SYS_REPEAT_SUBMIT_EXCEPTION); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
public void updatePoints(AliBusinessCircleOrder record) { | |||||
record.setUpdateTime(new Date()); | |||||
aliBusinessCircleOrderMapper.updatePoints(record); | |||||
} | |||||
@Override | |||||
public void exportData(AliBusinessCircleOrder circleOrder, HttpServletRequest request, HttpServletResponse response) { | |||||
List<AliBusinessCircleOrder> list = aliBusinessCircleOrderMapper.findList(circleOrder); | |||||
excelService.exportExcel(list, null, "支付宝商圈交易", AliBusinessCircleOrder.class, "支付宝商圈交易.xlsx", response, false); | |||||
} | |||||
@Override | |||||
public Integer sumCirclePayment(BusinessCircleBase circleOrder) { | |||||
Integer sumCirclePayment = aliBusinessCircleOrderMapper.sumCirclePayment(circleOrder); | |||||
return sumCirclePayment==null?0:sumCirclePayment; | |||||
} | |||||
@Override | |||||
public Integer sumCircleRefundAmount(BusinessCircleBase circleOrder) { | |||||
Integer sumCircleRefundAmount = aliBusinessCircleOrderMapper.sumCircleRefundAmount(circleOrder); | |||||
return sumCircleRefundAmount==null?0:sumCircleRefundAmount; | |||||
} | |||||
} |
@@ -1,556 +0,0 @@ | |||||
package com.iformall.service.impl; | |||||
import com.github.binarywang.wxpay.bean.businesscircle.MemberCardAuthorizeResult; | |||||
import com.github.binarywang.wxpay.bean.businesscircle.ParkingNotifyRequest; | |||||
import com.github.binarywang.wxpay.bean.businesscircle.PointsCommitStatusResult; | |||||
import com.github.binarywang.wxpay.bean.businesscircle.PointsNotifyRequest; | |||||
import com.github.binarywang.wxpay.exception.WxPayException; | |||||
import com.github.binarywang.wxpay.service.WxPayService; | |||||
import com.github.pagehelper.PageHelper; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.IdWorker; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.domain.po.*; | |||||
import com.iformall.domain.po.base.TenantEntity; | |||||
import com.iformall.domain.po.msg.AfterBusinessCreditMsg; | |||||
import com.iformall.enums.*; | |||||
import com.iformall.exception.MallinkException; | |||||
import com.iformall.mapper.WxBusinessCircleOrderMapper; | |||||
import com.iformall.mq.MqBaseProducer; | |||||
import com.iformall.service.*; | |||||
import com.iformall.utils.DateUtils; | |||||
import com.iformall.utils.MaUtil; | |||||
import com.iformall.utils.RedisLock; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import org.springframework.transaction.annotation.Propagation; | |||||
import org.springframework.transaction.annotation.Transactional; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.math.BigDecimal; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
@Service | |||||
public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderService { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
private final String WX_CIRCLE_KEY = "CIRCLE:WX:"; | |||||
@Autowired | |||||
ExcelService excelService; | |||||
@Autowired | |||||
RedisLock redisLock; | |||||
@Autowired | |||||
WxBusinessCircleOrderMapper wxBusinessCircleOrderMapper; | |||||
@Autowired | |||||
WxMerchantService wxMerchantService; | |||||
@Autowired | |||||
WxCUserService wxCUserService; | |||||
@Autowired | |||||
WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
@Autowired | |||||
WxCreditHistoryService creditHistoryService; | |||||
@Autowired | |||||
WxCouponSendService wxCouponSendService; | |||||
@Autowired | |||||
WxAppinfoService wxAppinfoService; | |||||
@Autowired | |||||
WxPayAccountService wxPayAccountService; | |||||
@Autowired | |||||
MqBaseProducer mqBaseProducer; | |||||
@Autowired | |||||
MaUtil maUtil; | |||||
@Override | |||||
public PageInfo<WxBusinessCircleOrder> listAsPage(WxBusinessCircleOrder record, Integer pageIndex, Integer pageSize) { | |||||
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxBusinessCircleOrderMapper.findList(record)); | |||||
} | |||||
@Override | |||||
public WxBusinessCircleOrder getById(Long id, String tenantId) { | |||||
WxBusinessCircleOrder recordQ = new WxBusinessCircleOrder(); | |||||
recordQ.setId(id); | |||||
recordQ.setTenantId(tenantId); | |||||
return wxBusinessCircleOrderMapper.getById(recordQ); | |||||
} | |||||
@Override | |||||
public WxBusinessCircleOrder detail(Long id, TenantEntity tenantInfo) { | |||||
WxBusinessCircleOrder order = this.getById(id, tenantInfo.getTenantId()); | |||||
if(order.getMerchantId() != null){ | |||||
order.setMerchant(wxMerchantService.selectById(order.getMerchantId())); | |||||
} | |||||
if(order.getCUserId() != null){ | |||||
order.setBasicInfo(wxCUserBasicInfoService.getById(id,tenantInfo.getFinalTenantId())); | |||||
} | |||||
// if(order.getIsRefund() != null && order.getIsRefund().equals(EnumYesOrNo.YES.getCode())){ | |||||
// | |||||
// } | |||||
return order; | |||||
} | |||||
@Override | |||||
public WxBusinessCircleOrder getOrderByTransactionId(String transactionId, String tenantId) { | |||||
WxBusinessCircleOrder recordQ = new WxBusinessCircleOrder(); | |||||
recordQ.setTransactionId(transactionId); | |||||
recordQ.setTenantId(tenantId); | |||||
return wxBusinessCircleOrderMapper.getOrderByTransactionId(recordQ); | |||||
} | |||||
@Override | |||||
public WxBusinessCircleOrder getRefundOrderByRefundId(String refundId, String tenantId) { | |||||
WxBusinessCircleOrder recordQ = new WxBusinessCircleOrder(); | |||||
recordQ.setRefundId(refundId); | |||||
recordQ.setTenantId(tenantId); | |||||
return wxBusinessCircleOrderMapper.getRefundOrderByRefundId(recordQ); | |||||
} | |||||
@Override | |||||
public List<WxBusinessCircleOrder> getRefundOrderByTransactionId(String transactionId, String tenantId) { | |||||
WxBusinessCircleOrder recordQ = new WxBusinessCircleOrder(); | |||||
recordQ.setTransactionId(transactionId); | |||||
recordQ.setTenantId(tenantId); | |||||
return wxBusinessCircleOrderMapper.getRefundOrderByTransactionId(recordQ); | |||||
} | |||||
@Override | |||||
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
public ResultData createOrder(WxBusinessCircleOrder record) { | |||||
String lockKey = StringUtils.join(WX_CIRCLE_KEY,record.getTransactionId(), ":",EnumYesOrNo.NO.getCode(),":", "lock"); | |||||
long time = System.currentTimeMillis() + 2000; | |||||
String timeStr = String.valueOf(time); | |||||
if (redisLock.lock2(lockKey, timeStr)) { | |||||
WxBusinessCircleOrder byTransactionId = this.getOrderByTransactionId(record.getTransactionId(),record.getTenantId()); | |||||
if(byTransactionId != null){ | |||||
logger.error("--Wx商圈付款--订单消息已存在---byTransactionId="+byTransactionId.getTransactionId()); | |||||
//同步积分状态 | |||||
this.sendsyncNotifyPointsMsg(record,byTransactionId.getId()); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
return new ResultData(); | |||||
// 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); | |||||
//TODO 第三方获取门店(标识可能发生变化) | |||||
// WxMerchant wxMerchant = wxMerchantService.getById(Long.parseLong(record.getWxShopNumber())); | |||||
WxMerchant wxMerchant = wxMerchantService.getMerchantByEncode(record.getWxShopNumber()); | |||||
if (wxMerchant != null) { | |||||
record.setMerchantId(wxMerchant.getId()); | |||||
record.setMerchantName(wxMerchant.getName()); | |||||
} else { | |||||
record.setMerchantName("未知门店"); | |||||
logger.error("--wx商圈付款通知消息未找到门店--shopName=" + record.getWxShopName() + "&shopNumber=" + record.getWxShopNumber()); | |||||
} | |||||
if(StringUtils.isNotBlank(record.getOpenid()) && StringUtils.isNotBlank(record.getAppid())){ | |||||
WxCUser userQ = new WxCUser(); | |||||
userQ.updateTenantInfo(record); | |||||
userQ.setOpenId(record.getOpenid()); | |||||
userQ.setAppId(record.getAppid()); | |||||
WxCUser user = wxCUserService.getByOpenId(userQ); | |||||
if (user != null && user.getUserId() != null) { | |||||
record.setCUserId(user.getUserId()); | |||||
} | |||||
} | |||||
if(record.getCUserId() == null){ | |||||
WxCUserBasicInfo byPhone = wxCUserBasicInfoService.registerByPhone(record, record.getCUserPhone(),null,null,null,null); | |||||
if(byPhone != null){ | |||||
record.setCUserNickName(byPhone.getNickName()); | |||||
record.setCUserPhone(byPhone.getPhone()); | |||||
}else{ | |||||
logger.error("--微信商圈付款通知消息未找到会员--1"); | |||||
} | |||||
}else{ | |||||
WxCUserBasicInfo byId = wxCUserBasicInfoService.getById(record.getCUserId(), record.getFinalTenantId()); | |||||
if(byId != null){ | |||||
record.setCUserNickName(byId.getNickName()); | |||||
record.setCUserPhone(byId.getPhone()); | |||||
}else{ | |||||
record.setCUserId(null); | |||||
logger.error("--微信商圈付款通知消息未找到会员--2"); | |||||
} | |||||
} | |||||
wxBusinessCircleOrderMapper.insertNoticeOrder(record); | |||||
Integer creditNum = 0; | |||||
if(record.getCUserId() != null){ | |||||
try { | |||||
wxCouponSendService.sendCouponToUser(EnumCouponSendSendType.B_MICROPAY, record,EnumPayWay.PAY_WAY_NOT_UNPAY_B_MA,EnumPayVersion.NO_VERSION); | |||||
} catch (Exception e) { | |||||
logger.error("支付发券: " + e.getMessage()); | |||||
} | |||||
Integer businessId = EnumBusiness.BUSINESS_ID6.getCode(); | |||||
if(wxMerchant != null){ | |||||
businessId = wxMerchant.getBusinessId(); | |||||
} | |||||
WxCreditHistory creditHistory = new WxCreditHistory(); | |||||
creditHistory.setTenantId(record.getFinalTenantId()); | |||||
creditHistory.setOperatorType(EnumUserType.BUSINESS_CIRCLE.getCode()); | |||||
creditHistory.setOperatorId(record.getCUserId()); | |||||
creditHistory.setCUserId(record.getCUserId()); | |||||
creditHistory.setCreateDate(now); | |||||
creditHistory.setCouponId(record.getId()); | |||||
creditHistory.setBusinessId(businessId); | |||||
creditHistory.setMerchantId(record.getMerchantId()); | |||||
creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode()); | |||||
creditHistory.setSpend(record.getPayAmount()); | |||||
creditHistory.setChangePurpose("微信商圈消费:商户["+record.getMerchantName()+"] ("+record.getPayAmountStr()+"元) "); | |||||
creditHistory = creditHistoryService.saveOrUpdate(creditHistory,record.getTenantId()); | |||||
if (creditHistory.getCreditNum() != null) { | |||||
creditNum = creditHistory.getCreditNum(); | |||||
} | |||||
if(creditNum == 0){ | |||||
redisLock.unlock(lockKey, timeStr); | |||||
return new ResultData(0); | |||||
} | |||||
record.setIncreasedPoints(creditNum); | |||||
record.setPointsUpdateTime(creditHistory.getCreateDate()); | |||||
this.updatePoints(record); | |||||
//同步积分 | |||||
this.sendsyncNotifyPointsMsg(record,record.getId()); | |||||
} | |||||
redisLock.unlock(lockKey, timeStr); | |||||
return new ResultData(creditNum); | |||||
} | |||||
}else { | |||||
logger.debug("CacheAspect 读库等待中, key:{}: " + lockKey); | |||||
try { | |||||
Thread.sleep(2000); | |||||
} catch (InterruptedException e) { | |||||
e.printStackTrace(); | |||||
}finally { | |||||
redisLock.unlock(lockKey, timeStr); | |||||
} | |||||
return new ResultData(ErrorCode.SYS_REPEAT_SUBMIT_EXCEPTION); | |||||
} | |||||
} | |||||
@Override | |||||
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
public ResultData insertRefundNoticeOrder(WxBusinessCircleOrder record) { | |||||
WxBusinessCircleOrder order = this.getOrderByTransactionId(record.getTransactionId(),record.getTenantId()); | |||||
if(order == null){ | |||||
logger.error("--Wx商圈退款--付款消息未找到--transactionId="+record.getTransactionId()); | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "付款消息未找到"); | |||||
}else{ | |||||
String lockKey = StringUtils.join(WX_CIRCLE_KEY,record.getRefundId(), ":",EnumYesOrNo.YES.getCode(),":", "lock"); | |||||
long time = System.currentTimeMillis() + 2000; | |||||
String timeStr = String.valueOf(time); | |||||
if (redisLock.lock2(lockKey, timeStr)) { | |||||
WxBusinessCircleOrder refundOrder = this.getRefundOrderByRefundId(record.getRefundId(),record.getTenantId()); | |||||
if(refundOrder != null){ | |||||
logger.error("--Ali商圈退款--退款消息已存在---RefundId="+record.getRefundId()); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "退款数据已存在"); | |||||
}else{ | |||||
List<WxBusinessCircleOrder> refundOrders = this.getRefundOrderByTransactionId(record.getTransactionId(),record.getTenantId()); | |||||
Integer amount = order.getPayAmount(); | |||||
Integer increasedPoints = order.getIncreasedPoints(); | |||||
Integer refundAmount = 0; | |||||
Integer refundIncreasedPoints = 0; | |||||
if(refundOrders != null && refundOrders.size()>0){ | |||||
for (WxBusinessCircleOrder ro:refundOrders) { | |||||
refundAmount += ro.getRefundAmount(); | |||||
refundIncreasedPoints += ro.getIncreasedPoints(); | |||||
} | |||||
} | |||||
if(record.getRefundAmount() == null){ | |||||
record.setRefundAmount(order.getPayAmount()-refundAmount); | |||||
} | |||||
if(refundAmount >= amount){ | |||||
logger.error("--Wx商圈退款--已经退款--transactionId="+record.getTransactionId()); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "已经退款"); | |||||
}else if((refundAmount + record.getRefundAmount()) > amount ){ | |||||
logger.error("--Wx商圈退款--退款金额超限--transactionId="+record.getTransactionId()); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
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); | |||||
if(record.getAmount() == null){ | |||||
record.setAmount(order.getAmount()); | |||||
} | |||||
if(record.getPayAmount() == null){ | |||||
record.setPayAmount(order.getPayAmount()); | |||||
} | |||||
record.setCUserId(order.getCUserId()); | |||||
record.setCUserNickName(order.getCUserNickName()); | |||||
record.setCUserPhone(order.getCUserPhone()); | |||||
record.setMerchantId(order.getMerchantId()); | |||||
record.setMerchantName(order.getMerchantName()); | |||||
wxBusinessCircleOrderMapper.insertRefundNoticeOrder(record); | |||||
if((refundAmount + record.getRefundAmount()) == amount){ | |||||
order.setOrderStatus(2);//全额退款 | |||||
}else{ | |||||
order.setOrderStatus(1);//部分退款 | |||||
} | |||||
order.setUpdateTime(now); | |||||
wxBusinessCircleOrderMapper.updateOrderStatus(order); | |||||
int creditNum = 0; | |||||
if(order.getEarnPoints().equals(EnumYesOrNo.YES.getCode())){ | |||||
WxCreditHistory creditHistory = new WxCreditHistory(); | |||||
creditHistory.setTenantId(record.getFinalTenantId()); | |||||
creditHistory.setOperatorType(EnumUserType.BUSINESS_CIRCLE.getCode()); | |||||
creditHistory.setOperatorId(record.getCUserId()); | |||||
creditHistory.setCUserId(record.getCUserId()); | |||||
creditHistory.setCreateDate(new Date()); | |||||
creditHistory.setCouponId(record.getId()); | |||||
creditHistory.setMerchantId(record.getMerchantId()); | |||||
creditHistory.setCreditType(EnumScoreType.REFUND_CONSUMPTION.getCode()); | |||||
int points = 0; | |||||
if((refundAmount + record.getRefundAmount()) == amount){ | |||||
points = increasedPoints - refundIncreasedPoints; | |||||
}else{ | |||||
points = new BigDecimal(order.getIncreasedPoints()) | |||||
.divide(new BigDecimal(order.getPayAmount()),2,BigDecimal.ROUND_HALF_UP) | |||||
.multiply(new BigDecimal(record.getRefundAmount())) | |||||
.intValue(); | |||||
} | |||||
creditHistory.setCreditNum(points); | |||||
creditHistory.setSpend(0-record.getRefundAmount()); | |||||
creditHistory.setChangePurpose("微信商圈退款:商户["+record.getMerchantName()+"] ("+record.getRefundAmountStr()+"元) "); | |||||
creditHistory = creditHistoryService.saveOrUpdate(creditHistory,record.getTenantId()); | |||||
if (creditHistory.getCreditNum() != null) { | |||||
creditNum = creditHistory.getCreditNum(); | |||||
} | |||||
if(creditNum != 0){ | |||||
record.setIncreasedPoints(creditNum); | |||||
record.setPointsUpdateTime(creditHistory.getCreateDate()); | |||||
this.updatePoints(record); | |||||
} | |||||
} | |||||
redisLock.unlock(lockKey, timeStr); | |||||
return new ResultData(creditNum); | |||||
} | |||||
} | |||||
}else { | |||||
logger.debug("CacheAspect 读库等待中, key:{}: " + lockKey); | |||||
try { | |||||
Thread.sleep(2000); | |||||
} catch (InterruptedException e) { | |||||
e.printStackTrace(); | |||||
}finally { | |||||
redisLock.unlock(lockKey, timeStr); | |||||
} | |||||
return new ResultData(ErrorCode.SYS_REPEAT_SUBMIT_EXCEPTION); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
public void updatePoints(WxBusinessCircleOrder record) { | |||||
record.setUpdateTime(new Date()); | |||||
wxBusinessCircleOrderMapper.updatePoints(record); | |||||
} | |||||
@Override | |||||
public void notifyPoints(WxBusinessCircleOrder record){ | |||||
if(EnumYesOrNo.YES.getCode().equals(record.getIsPointsNotify())){ | |||||
logger.info("该商圈订单已同步积分"+record.getId()); | |||||
return; | |||||
} | |||||
WxPayService wxPayService = wxPayAccountService.getWxPayService(record.getTenantId()); | |||||
PointsNotifyRequest request = new PointsNotifyRequest(); | |||||
request.setSubMchid(wxPayService.getConfig().getSubMchId()); | |||||
request.setTransactionId(record.getTransactionId()); | |||||
request.setAppid(wxPayService.getConfig().getAppId()); | |||||
request.setOpenid(record.getOpenid()); | |||||
if(record.getIncreasedPoints() != null && record.getIncreasedPoints() > 0 ){ | |||||
request.setEarnPoints(true); | |||||
request.setIncreasedPoints(record.getIncreasedPoints()); | |||||
request.setPointsUpdateTime(DateUtils.toRfc3339Str(record.getPointsUpdateTime())); | |||||
}else{ | |||||
request.setEarnPoints(false); | |||||
request.setIncreasedPoints(0); | |||||
request.setPointsUpdateTime(DateUtils.toRfc3339Str(new Date())); | |||||
request.setNoPointsRemarks("该订单不参与积分活动"); | |||||
} | |||||
try { | |||||
String result = wxPayService.getBusinessCircleService().notifyPoints(request); | |||||
logger.info("微信商圈同步积分请求结果----"+result); | |||||
record.setUpdateTime(new Date()); | |||||
this.updateIsPointsNotify(record); | |||||
} catch (WxPayException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
@Override | |||||
public void sendsyncNotifyPointsMsg(TenantEntity tenantEntity, Long businessCircleOrderId) { | |||||
AfterBusinessCreditMsg msg = new AfterBusinessCreditMsg(); | |||||
msg.updateTenantInfo(tenantEntity); | |||||
msg.setMsgType(EnumMsgRecordType.AFTER_BUSINESS_CREDIT.getCode()); | |||||
msg.setBusinessCircleOrderId(businessCircleOrderId); | |||||
mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
} | |||||
@Override | |||||
public void updateIsPointsNotify(WxBusinessCircleOrder record) { | |||||
record.setUpdateTime(new Date()); | |||||
wxBusinessCircleOrderMapper.updateIsPointsNotify(record); | |||||
} | |||||
@Override | |||||
public void exportData(WxBusinessCircleOrder circleOrder, HttpServletRequest request, HttpServletResponse response) { | |||||
List<WxBusinessCircleOrder> list = wxBusinessCircleOrderMapper.findList(circleOrder); | |||||
excelService.exportExcel(list, null, "微信商圈交易", WxBusinessCircleOrder.class, "微信商圈交易.xlsx", response, false); | |||||
} | |||||
@Override | |||||
public Integer sumCirclePayment(BusinessCircleBase circleOrder) { | |||||
Integer sumCirclePayment = wxBusinessCircleOrderMapper.sumCirclePayment(circleOrder); | |||||
return sumCirclePayment==null?0:sumCirclePayment; | |||||
} | |||||
@Override | |||||
public Integer sumCircleRefundAmount(BusinessCircleBase circleOrder) { | |||||
Integer sumCircleRefundAmount = wxBusinessCircleOrderMapper.sumCircleRefundAmount(circleOrder); | |||||
return sumCircleRefundAmount==null?0:sumCircleRefundAmount; | |||||
} | |||||
@Override | |||||
public ResultData syncauthorizeState(TenantEntity tenantEntity, String openid) { | |||||
WxAppinfo cAppInfo = wxAppinfoService.getCAppInfoFromRedis(tenantEntity.getTenantId(), EnumAppPlat.WX); | |||||
if(cAppInfo == null){ | |||||
return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||||
} | |||||
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(cAppInfo.getPayId()); | |||||
if(payAccount == null){ | |||||
return new ResultData(ErrorCode.API_KEY_NOT_FOUND); | |||||
} | |||||
if(!EnumBusinessType.BUSINESS_3.getCode().equals(payAccount.getBusinessType())){ | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"未开通商圈或不支持此项操作"); | |||||
} | |||||
try { | |||||
WxPayService wxPayService = maUtil.getWxPayService(cAppInfo, payAccount); | |||||
MemberCardAuthorizeResult authorizations = wxPayService.getBusinessCircleService().getAuthorizations(openid); | |||||
EnumBusinessCircleAuthorizeState authorizeState = EnumBusinessCircleAuthorizeState.getEnum(authorizations.getAuthorizeState()); | |||||
if(!EnumBusinessCircleAuthorizeState.UNAUTHORIZED.equals(authorizeState)){ | |||||
WxCUser updCuser = new WxCUser(); | |||||
updCuser.updateTenantInfo(tenantEntity); | |||||
updCuser.setOpenId(authorizations.getOpenid()); | |||||
updCuser.setAuthorizeState(authorizeState.getCode()); | |||||
updCuser.setAuthorizeTime(DateUtils.rfc3339Formatter(authorizations.getAuthorizeTime())); | |||||
updCuser.setDeauthorizeTime(DateUtils.rfc3339Formatter(authorizations.getDeauthorizeTime())); | |||||
wxCUserService.updateAuthorizeStateByOpenId(updCuser); | |||||
} | |||||
return new ResultData(authorizeState); | |||||
} catch (WxPayException e) { | |||||
e.printStackTrace(); | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||||
} | |||||
} | |||||
@Override | |||||
public ResultData getPointsCommitStatus(TenantEntity tenantEntity, String openId) { | |||||
WxAppinfo cAppInfo = wxAppinfoService.getCAppInfoFromRedis(tenantEntity.getTenantId(), EnumAppPlat.WX); | |||||
if(cAppInfo == null){ | |||||
return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||||
} | |||||
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(cAppInfo.getPayId()); | |||||
if(payAccount == null){ | |||||
return new ResultData(ErrorCode.API_KEY_NOT_FOUND); | |||||
} | |||||
if(!EnumBusinessType.BUSINESS_3.getCode().equals(payAccount.getBusinessType())){ | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"未开通商圈或不支持此项操作"); | |||||
} | |||||
try { | |||||
WxPayService wxPayService = maUtil.getWxPayService(cAppInfo, payAccount); | |||||
PointsCommitStatusResult pointsCommitStatus = wxPayService.getBusinessCircleService().getPointsCommitStatus(payAccount.getBrandid(), openId); | |||||
return new ResultData(pointsCommitStatus); | |||||
} catch (WxPayException e) { | |||||
e.printStackTrace(); | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||||
} | |||||
} | |||||
@Override | |||||
public ResultData syncParkings(TenantEntity tenantEntity, String openId, String plate_number, String state, Date time) { | |||||
WxAppinfo cAppInfo = wxAppinfoService.getCAppInfoFromRedis(tenantEntity.getTenantId(), EnumAppPlat.WX); | |||||
if(cAppInfo == null){ | |||||
return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||||
} | |||||
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(cAppInfo.getPayId()); | |||||
if(payAccount == null){ | |||||
return new ResultData(ErrorCode.API_KEY_NOT_FOUND); | |||||
} | |||||
if(!EnumBusinessType.BUSINESS_3.getCode().equals(payAccount.getBusinessType())){ | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"未开通商圈或不支持此项操作"); | |||||
} | |||||
try { | |||||
WxPayService wxPayService = maUtil.getWxPayService(cAppInfo, payAccount); | |||||
ParkingNotifyRequest request = new ParkingNotifyRequest(); | |||||
request.setBrandid(payAccount.getBrandid()); | |||||
request.setOpenid(openId); | |||||
request.setPlateNumber(plate_number); | |||||
request.setState(state); | |||||
request.setTime(DateUtils.toRfc3339Str(time)); | |||||
wxPayService.getBusinessCircleService().notifyParkings(request); | |||||
return new ResultData(); | |||||
} catch (WxPayException e) { | |||||
e.printStackTrace(); | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||||
} | |||||
} | |||||
@Override | |||||
public void sendSyncParkingsMsg(TenantEntity tenantEntity, Long carCmdLogId) { | |||||
//停车出入场通知 todo | |||||
// AfterCarInOutMsg msg = new AfterCarInOutMsg(); | |||||
// msg.updateTenantInfo(tenantEntity); | |||||
// msg.setMsgType(EnumMsgRecordType.AFTER_ADD_CREDIT.getCode()); | |||||
// msg.setCarCmdLogId(carCmdLogId); | |||||
// mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
} | |||||
} |
@@ -7,7 +7,6 @@ import com.iformall.domain.po.base.TenantEntity; | |||||
import com.iformall.enums.EnumCarCmd; | import com.iformall.enums.EnumCarCmd; | ||||
import com.iformall.mapper.WxCarCmdLogMapper; | import com.iformall.mapper.WxCarCmdLogMapper; | ||||
import com.iformall.mapper.WxMallMapper; | import com.iformall.mapper.WxMallMapper; | ||||
import com.iformall.service.WxBusinessCircleOrderService; | |||||
import com.iformall.service.WxCarCmdLogService; | import com.iformall.service.WxCarCmdLogService; | ||||
import com.iformall.service.WxMallService; | import com.iformall.service.WxMallService; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
@@ -33,9 +32,6 @@ public class WxCarCmdLogServiceImpl implements WxCarCmdLogService { | |||||
@Autowired | @Autowired | ||||
WxMallService wxMallService; | WxMallService wxMallService; | ||||
@Autowired | |||||
WxBusinessCircleOrderService wxBusinessCircleOrderService; | |||||
@Override | @Override | ||||
public PageInfo<WxCarCmdLog> listAsPage(WxCarCmdLog record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxCarCmdLog> listAsPage(WxCarCmdLog record, Integer pageIndex, Integer pageSize) { | ||||
@@ -54,22 +50,11 @@ public class WxCarCmdLogServiceImpl implements WxCarCmdLogService { | |||||
final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
wxCarCmdLogMapper.insert(record); | wxCarCmdLogMapper.insert(record); | ||||
this.afterCarInOrOut(record); | |||||
} else { | } else { | ||||
wxCarCmdLogMapper.updateById(record); | wxCarCmdLogMapper.updateById(record); | ||||
} | } | ||||
} | } | ||||
private void afterCarInOrOut(WxCarCmdLog record){ | |||||
if(StringUtils.isBlank(record.getPlateNumber())){ | |||||
return; | |||||
} | |||||
if(EnumCarCmd.getCarIn().contains(record.getCmdType()) | |||||
|| EnumCarCmd.getCarOut().contains(record.getCmdType())){ | |||||
wxBusinessCircleOrderService.sendSyncParkingsMsg(record,record.getId()); | |||||
} | |||||
} | |||||
@Override | @Override | ||||
public void deleteById(Long id,String tenantId) { | public void deleteById(Long id,String tenantId) { | ||||
wxCarCmdLogMapper.deleteById(id,tenantId); | wxCarCmdLogMapper.deleteById(id,tenantId); | ||||
@@ -423,26 +423,6 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
logger.error("收银台发券条件判断错误:ID=" + wxCouponSend.getId() + e.getMessage()); | logger.error("收银台发券条件判断错误:ID=" + wxCouponSend.getId() + e.getMessage()); | ||||
} | } | ||||
}else if(param instanceof BusinessCircleBase){ | |||||
BusinessCircleBase circleBase = (BusinessCircleBase) param; | |||||
try { | |||||
JSONObject jo = JSONObject.parseObject(wxCouponSend.getConditions()); | |||||
Long sendId = jo.getLong("id"); | |||||
int miniPayment = jo.getIntValue("miniPayment")*100; | |||||
if(sendId == null && circleBase.getPayAmount().intValue() >= miniPayment){ | |||||
return true; | |||||
} | |||||
if (sendId != null && circleBase.getMerchantId() != null | |||||
&& circleBase.getMerchantId().equals(sendId) | |||||
&& circleBase.getPayAmount().intValue() >= miniPayment) { | |||||
return true; | |||||
} | |||||
logger.info("商圈收银发券条件判断--不满足{}"+circleBase.getId()); | |||||
} catch (Exception e) { | |||||
logger.error("商圈收银条件判断错误:ID=" + wxCouponSend.getId() + e.getMessage()); | |||||
} | |||||
} | } | ||||
return false; | return false; | ||||
@@ -489,11 +469,6 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
cUserId = order.getCUserId(); | cUserId = order.getCUserId(); | ||||
tenantEntity = order; | tenantEntity = order; | ||||
break; | break; | ||||
}else if(param instanceof BusinessCircleBase){ | |||||
BusinessCircleBase circleBase = (BusinessCircleBase) param; | |||||
cUserId = circleBase.getCUserId(); | |||||
tenantEntity = circleBase; | |||||
break; | |||||
}else{ | }else{ | ||||
return false; | return false; | ||||
} | } | ||||
@@ -1,317 +0,0 @@ | |||||
package com.iformall.service.impl; | |||||
import com.alibaba.fastjson.JSON; | |||||
import com.github.binarywang.wxpay.bean.businesscircle.MemberCardAuthorizeResult; | |||||
import com.github.binarywang.wxpay.bean.membercard.MemberCardResult; | |||||
import com.github.binarywang.wxpay.bean.membercard.MemberCardRightsRequest; | |||||
import com.github.binarywang.wxpay.bean.membercard.MemberCardUpdRequest; | |||||
import com.github.binarywang.wxpay.exception.WxPayException; | |||||
import com.github.binarywang.wxpay.service.WxPayService; | |||||
import com.github.pagehelper.PageHelper; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.IdWorker; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.domain.po.*; | |||||
import com.iformall.domain.po.base.TenantEntity; | |||||
import com.iformall.domain.po.msg.AfterAddCreditMsg; | |||||
import com.iformall.domain.po.msg.AfterAddScoreMsg; | |||||
import com.iformall.domain.po.msg.FmInsideCLoginMsg; | |||||
import com.iformall.domain.po.msg.SyncMemberCardMsg; | |||||
import com.iformall.enums.*; | |||||
import com.iformall.mapper.WxMemberCardMapper; | |||||
import com.iformall.mq.MqBaseProducer; | |||||
import com.iformall.service.*; | |||||
import com.iformall.utils.DateUtils; | |||||
import com.iformall.utils.MaUtil; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
@Service | |||||
public class WxMemberCardServiceImpl implements WxMemberCardService { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Autowired | |||||
WxMemberCardMapper wxMemberCardMapper; | |||||
@Autowired | |||||
WxAppinfoService wxAppinfoService; | |||||
@Autowired | |||||
WxPayAccountService wxPayAccountService; | |||||
@Autowired | |||||
WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
@Autowired | |||||
private MqBaseProducer mqBaseProducer; | |||||
@Autowired | |||||
MaUtil maUtil; | |||||
@Override | |||||
public PageInfo<WxMemberCard> listAsPage(WxMemberCard record, Integer pageIndex, Integer pageSize) { | |||||
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMemberCardMapper.findList(record)); | |||||
} | |||||
@Override | |||||
public ResultData saveorupdate(WxMemberCard record) { | |||||
Date now = new Date(); | |||||
if(record.getId() == null){ | |||||
final IdWorker idWorker = IdWorker.get(); | |||||
record.setId(idWorker.nextId()); | |||||
record.setCreateDate(now); | |||||
record.setUpdateDate(now); | |||||
wxMemberCardMapper.insert(record); | |||||
}else{ | |||||
record.setUpdateDate(now); | |||||
wxMemberCardMapper.updateById(record); | |||||
} | |||||
return new ResultData(); | |||||
} | |||||
@Override | |||||
public ResultData saveorupdateByCode(WxMemberCard record) { | |||||
Long id = wxMemberCardMapper.getIdByCode(record); | |||||
Date now = new Date(); | |||||
if(id == null){ | |||||
final IdWorker idWorker = IdWorker.get(); | |||||
id = idWorker.nextId(); | |||||
record.setId(id); | |||||
if(record.getCreateDate() == null){ | |||||
record.setCreateDate(now); | |||||
} | |||||
record.setUpdateDate(record.getCreateDate()); | |||||
wxMemberCardMapper.insert(record); | |||||
if(record.getCuserId() != null){ | |||||
TenantEntity tenantEntity = new TenantEntity(); | |||||
tenantEntity.setTenantId(record.getTenantId()); | |||||
tenantEntity.setParentTenantId(record.getParentTenantId()); | |||||
this.sendsyncMemberCardBonusMsg(tenantEntity,record.getCuserId(),null,null); | |||||
} | |||||
}else{ | |||||
record.setId(id); | |||||
if(record.getUpdateDate() == null){ | |||||
record.setUpdateDate(now); | |||||
} | |||||
wxMemberCardMapper.updateById(record); | |||||
} | |||||
return new ResultData(); | |||||
} | |||||
@Override | |||||
public ResultData delUserCardStatusByCode(WxMemberCard record) { | |||||
record.setUserCardStatus(EnumMemberCardStatus.DELETE.getCode()); | |||||
if(record.getUpdateDate() == null){ | |||||
record.setUpdateDate(new Date()); | |||||
} | |||||
wxMemberCardMapper.deleteByCode(record); | |||||
return new ResultData(); | |||||
} | |||||
@Override | |||||
public ResultData syncMemberCard(TenantEntity tenantEntity, String card_id, String code) { | |||||
WxAppinfo cAppInfo = wxAppinfoService.getCAppInfoFromRedis(tenantEntity.getTenantId(), EnumAppPlat.WX); | |||||
if(cAppInfo == null){ | |||||
return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||||
} | |||||
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(cAppInfo.getPayId()); | |||||
if(payAccount == null){ | |||||
return new ResultData(ErrorCode.API_KEY_NOT_FOUND); | |||||
} | |||||
if(!EnumBusinessType.BUSINESS_3.getCode().equals(payAccount.getBusinessType())){ | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"未开通商圈或不支持此项操作"); | |||||
} | |||||
try { | |||||
WxPayService wxPayService = maUtil.getWxPayServiceBySelfModel(cAppInfo, payAccount); | |||||
MemberCardResult memberCard = wxPayService.getMemberCardService().getMemberCard(card_id, code); | |||||
WxMemberCard record = new WxMemberCard(); | |||||
record.setTenantId(tenantEntity.getTenantId()); | |||||
record.setParentTenantId(tenantEntity.getParentTenantId()); | |||||
record.updateFinalTenantId(tenantEntity); | |||||
record.setCardId(card_id); | |||||
record.setCardCode(code); | |||||
record.setOpenId(memberCard.getOpenid()); | |||||
record.setMembershipNumber(memberCard.getMembershipNumber()); | |||||
record.setLevel(memberCard.getLevel()); | |||||
record.setNickname(memberCard.getNickname()); | |||||
record.setHeadImageUrl(memberCard.getHeadImageUrl()); | |||||
record.setBackgroundPictureUrl(memberCard.getBackgroundPictureUrl()); | |||||
record.setBalance(memberCard.getBalance()); | |||||
EnumMemberCardStatus enumMemberCardStatus = EnumMemberCardStatus.getEnum(memberCard.getUserCardStatus()); | |||||
if(enumMemberCardStatus != null){ | |||||
record.setUserCardStatus(enumMemberCardStatus.getCode()); | |||||
} | |||||
record.setUserInformation(JSON.toJSONString(memberCard.getUserInformation())); | |||||
record.setBonusValue(memberCard.getBonusValue()); | |||||
if(memberCard.getServiceModules() != null){ | |||||
record.setServiceModules(JSON.toJSONString(memberCard.getServiceModules())); | |||||
} | |||||
record.setMemberPriceWord(memberCard.getMemberPriceWord()); | |||||
record.setFapiaoJumpWord(memberCard.getFapiaoJumpWord()); | |||||
if(memberCard.getGuide() != null){ | |||||
record.setGuide(JSON.toJSONString(memberCard.getGuide())); | |||||
} | |||||
// MemberCardResult.UserInformation userInformation = memberCard.getUserInformation(); | |||||
// List<MemberCardResult.CommonField> commonFieldList = userInformation.getCommonFieldList(); | |||||
// String phone = null, name = null, avatarUrl = null; | |||||
// Integer sex = null; | |||||
// for (MemberCardResult.CommonField commonField:commonFieldList) { | |||||
// /** | |||||
// * 平台提供了一些通用的开卡字段供开发者选用 | |||||
// * USER_FORM_FLAG_MOBILE:手机号 | |||||
// * USER_FORM_FLAG_SEX:性别 | |||||
// * USER_FORM_FLAG_NAME:姓名 | |||||
// * USER_FORM_FLAG_BIRTHDAY:生日 | |||||
// * USER_FORM_FLAG_ADDRESS:地址 | |||||
// * USER_FORM_FLAG_EMAIL:邮箱 | |||||
// * USER_FORM_FLAG_CITY:城市 | |||||
// */ | |||||
// if("USER_FORM_FLAG_MOBILE".equals(commonField.getName())){ | |||||
// phone = commonField.getValue(); | |||||
// }else if("USER_FORM_FLAG_SEX".equals(commonField.getName())){ | |||||
// if("男".equals(commonField.getValue())){ | |||||
// sex = 1; | |||||
// }else if("女".equals(commonField.getValue())){ | |||||
// sex = 2; | |||||
// }else{ | |||||
// sex = 0; | |||||
// } | |||||
// }else if("USER_FORM_FLAG_NAME".equals(commonField.getName())){ | |||||
// name = commonField.getValue(); | |||||
// } | |||||
// } | |||||
// WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.registerByPhone(tenantEntity, phone, null,name, sex, avatarUrl); | |||||
WxMemberCard old = wxMemberCardMapper.getByCode(record); | |||||
if(old != null){ | |||||
record.setId(old.getId()); | |||||
} | |||||
// if(basicInfo != null && (old == null || !basicInfo.getId().equals(old.getUserId()))){ | |||||
// record.setUserId(basicInfo.getId()); | |||||
// } | |||||
this.saveorupdate(record); | |||||
// if(record.getUserId() != null){ | |||||
// this.sendsyncMemberCardBonusMsg(tenantEntity,record.getUserId(),null); | |||||
//// this.sendsyncMemberCardLevelMsg(tenantEntity,record.getUserId(),null); | |||||
// } | |||||
return new ResultData(); | |||||
} catch (WxPayException e) { | |||||
e.printStackTrace(); | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||||
} | |||||
} | |||||
@Override | |||||
public void sendSyncMemberCardMsg(TenantEntity tenantEntity, String card_id, String code) { | |||||
SyncMemberCardMsg msg = new SyncMemberCardMsg(); | |||||
msg.updateTenantInfo(tenantEntity); | |||||
msg.setMsgType(EnumMsgRecordType.SYNC_MEMBER_CARD.getCode()); | |||||
msg.setCardId(card_id); | |||||
msg.setCode(code); | |||||
mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
} | |||||
@Override | |||||
public ResultData syncMemberCardLevel(TenantEntity tenantEntity, String card_id, String code,String markid, | |||||
String level, Boolean need_inform_level) { | |||||
WxAppinfo cAppInfo = wxAppinfoService.getCAppInfoFromRedis(tenantEntity.getTenantId(), EnumAppPlat.WX); | |||||
if(cAppInfo == null){ | |||||
return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||||
} | |||||
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(cAppInfo.getPayId()); | |||||
if(payAccount == null){ | |||||
return new ResultData(ErrorCode.API_KEY_NOT_FOUND); | |||||
} | |||||
if(!EnumBusinessType.BUSINESS_3.getCode().equals(payAccount.getBusinessType())){ | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"未开通商圈或不支持此项操作"); | |||||
} | |||||
try { | |||||
WxPayService wxPayService = maUtil.getWxPayServiceBySelfModel(cAppInfo, payAccount); | |||||
MemberCardUpdRequest request = new MemberCardUpdRequest(); | |||||
request.setLevel(level); | |||||
request.setOutRequestNo(markid); | |||||
request.setNeedInformLevel(need_inform_level); | |||||
wxPayService.getMemberCardService().updMemberCard(card_id,code,request); | |||||
this.sendSyncMemberCardMsg(tenantEntity,card_id,code); | |||||
return new ResultData(); | |||||
} catch (WxPayException e) { | |||||
e.printStackTrace(); | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||||
} | |||||
} | |||||
@Override | |||||
public void sendsyncMemberCardLevelMsg(TenantEntity tenantEntity, Long baseUserId, Long scoreHistoryId) { | |||||
//todo 暂不推送等级给商圈 | |||||
// AfterAddScoreMsg msg = new AfterAddScoreMsg(); | |||||
// msg.updateTenantInfo(tenantEntity); | |||||
// msg.setMsgType(EnumMsgRecordType.AFTER_ADD_SCORE.getCode()); | |||||
// msg.setBasicUserId(baseUserId); | |||||
// msg.setScoreHistoryId(scoreHistoryId); | |||||
// mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
} | |||||
@Override | |||||
public ResultData syncMemberCardBonus(TenantEntity tenantEntity, String card_id, String code,String markid, | |||||
int before_bonus_value,int bonus_value, Boolean need_inform_bonus) { | |||||
WxAppinfo cAppInfo = wxAppinfoService.getCAppInfoFromRedis(tenantEntity.getTenantId(), EnumAppPlat.WX); | |||||
if(cAppInfo == null){ | |||||
return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||||
} | |||||
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(cAppInfo.getPayId()); | |||||
if(payAccount == null){ | |||||
return new ResultData(ErrorCode.API_KEY_NOT_FOUND); | |||||
} | |||||
if(!EnumBusinessType.BUSINESS_3.getCode().equals(payAccount.getBusinessType())){ | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"未开通商圈或不支持此项操作"); | |||||
} | |||||
try { | |||||
WxPayService wxPayService = maUtil.getWxPayServiceBySelfModel(cAppInfo, payAccount); | |||||
MemberCardRightsRequest request = new MemberCardRightsRequest(); | |||||
request.setBeforeBonusValue(before_bonus_value); | |||||
request.setBonusValue(bonus_value); | |||||
request.setAddBonusValue(bonus_value - before_bonus_value); | |||||
request.setOutRequestNo(markid); | |||||
request.setNeedInformBonus(need_inform_bonus); | |||||
wxPayService.getMemberCardService().setMemberCardRights(card_id,code,request); | |||||
this.sendSyncMemberCardMsg(tenantEntity,card_id,code); | |||||
return new ResultData(); | |||||
} catch (WxPayException e) { | |||||
e.printStackTrace(); | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||||
} | |||||
} | |||||
@Override | |||||
public void sendsyncMemberCardBonusMsg(TenantEntity tenantEntity, Long cuserId, Long baseUserId, Long creditHistoryId) { | |||||
AfterAddCreditMsg msg = new AfterAddCreditMsg(); | |||||
msg.updateTenantInfo(tenantEntity); | |||||
msg.setMsgType(EnumMsgRecordType.AFTER_ADD_CREDIT.getCode()); | |||||
if(cuserId != null){ | |||||
msg.setCuserId(cuserId); | |||||
}else if(baseUserId != null){ | |||||
msg.setBasicUserId(baseUserId); | |||||
}else { | |||||
logger.error("商圈会员积分同步消息发送失败"); | |||||
} | |||||
msg.setCreditHistoryId(creditHistoryId); | |||||
mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
} | |||||
} |
@@ -1,655 +0,0 @@ | |||||
package com.iformall.service.impl; | |||||
import com.github.pagehelper.PageHelper; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.IdWorker; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.domain.po.*; | |||||
import com.iformall.domain.po.base.TenantEntity; | |||||
import com.iformall.domain.vo.WxThirdPartyOrdersVo; | |||||
import com.iformall.enums.*; | |||||
import com.iformall.exception.MallinkException; | |||||
import com.iformall.mapper.WxThirdPartyOrdersMapper; | |||||
import com.iformall.service.*; | |||||
import com.iformall.utils.RedisLock; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import org.springframework.transaction.annotation.Propagation; | |||||
import org.springframework.transaction.annotation.Transactional; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.math.BigDecimal; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
@Service | |||||
public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
private static final String THIRD_CIRCLE_KEY = "CIRCLE:TH:"; | |||||
@Autowired | |||||
ExcelService excelService; | |||||
@Autowired | |||||
RedisLock redisLock; | |||||
@Autowired | |||||
WxThirdPartyOrdersMapper wxThirdPartyOrdersMapper; | |||||
@Autowired | |||||
WxMerchantService wxMerchantService; | |||||
@Autowired | |||||
WxCUserService wxCUserService; | |||||
@Autowired | |||||
WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
@Autowired | |||||
WxCreditHistoryService wxCreditHistoryService; | |||||
@Autowired | |||||
WxCouponSendService wxCouponSendService; | |||||
@Override | |||||
public PageInfo<WxThirdPartyOrders> listAsPage(WxThirdPartyOrders record, Integer pageIndex, Integer pageSize) { | |||||
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxThirdPartyOrdersMapper.findList(record)); | |||||
} | |||||
@Override | |||||
public WxThirdPartyOrders getById(Long id, String tenantId) { | |||||
WxThirdPartyOrders recordQ = new WxThirdPartyOrders(); | |||||
recordQ.setId(id); | |||||
recordQ.setTenantId(tenantId); | |||||
return wxThirdPartyOrdersMapper.getById(recordQ); | |||||
} | |||||
@Override | |||||
public WxThirdPartyOrders detail(Long id, TenantEntity tenantInfo) { | |||||
WxThirdPartyOrders order = this.getById(id, tenantInfo.getTenantId()); | |||||
if(order.getMerchantId() != null){ | |||||
order.setMerchant(wxMerchantService.selectById(order.getMerchantId())); | |||||
} | |||||
if(order.getCUserId() != null){ | |||||
order.setBasicInfo(wxCUserBasicInfoService.getById(id,tenantInfo.getFinalTenantId())); | |||||
} | |||||
// if(order.getIsRefund() != null && order.getIsRefund().equals(EnumYesOrNo.YES.getCode())){ | |||||
// | |||||
// } | |||||
return order; | |||||
} | |||||
@Override | |||||
public WxThirdPartyOrders getOrderByTransactionId(EnumThirdOrderType orderType, String transactionId, String tenantId) { | |||||
WxThirdPartyOrders recordQ = new WxThirdPartyOrders(); | |||||
recordQ.setSourceType(orderType.getCode()); | |||||
recordQ.setTransactionId(transactionId); | |||||
recordQ.setTenantId(tenantId); | |||||
return wxThirdPartyOrdersMapper.getOrderByTransactionId(recordQ); | |||||
} | |||||
@Override | |||||
public WxThirdPartyOrders getRefundOrderByRefundId(EnumThirdOrderType orderType,String refundId, String tenantId) { | |||||
WxThirdPartyOrders recordQ = new WxThirdPartyOrders(); | |||||
recordQ.setSourceType(orderType.getCode()); | |||||
recordQ.setRefundId(refundId); | |||||
recordQ.setTenantId(tenantId); | |||||
return wxThirdPartyOrdersMapper.getRefundOrderByRefundId(recordQ); | |||||
} | |||||
@Override | |||||
public List<WxThirdPartyOrders> getRefundOrderByTransactionId(EnumThirdOrderType orderType, String transactionId, String tenantId) { | |||||
WxThirdPartyOrders recordQ = new WxThirdPartyOrders(); | |||||
recordQ.setSourceType(orderType.getCode()); | |||||
recordQ.setTransactionId(transactionId); | |||||
recordQ.setTenantId(tenantId); | |||||
return wxThirdPartyOrdersMapper.getRefundOrderByTransactionId(recordQ); | |||||
} | |||||
@Override | |||||
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
public ResultData createOrder(WxThirdPartyOrders record) { | |||||
String lockKey = StringUtils.join(THIRD_CIRCLE_KEY,record.getTransactionId(), ":",EnumYesOrNo.NO.getCode(),":", "lock"); | |||||
long time = System.currentTimeMillis() + 2000; | |||||
String timeStr = String.valueOf(time); | |||||
if (redisLock.lock2(lockKey, timeStr)) { | |||||
WxThirdPartyOrders byTransactionId = this.getOrderByTransactionId(EnumThirdOrderType.RMB_PAY,record.getTransactionId(),record.getTenantId()); | |||||
if(byTransactionId != null){ | |||||
logger.error("--第三方付款--通知消息已存在---byTransactionId="+byTransactionId.getTransactionId()); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
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.RMB_PAY.getCode()); | |||||
//TODO 第三方获取门店(标识可能发生变化) | |||||
// WxMerchant wxMerchant = wxMerchantService.getById(Long.parseLong(record.getShopNumber())); | |||||
WxMerchant wxMerchant = wxMerchantService.getMerchantByEncode(record.getShopNumber()); | |||||
if(wxMerchant != null){ | |||||
record.setMerchantId(wxMerchant.getId()); | |||||
record.setMerchantName(wxMerchant.getName()); | |||||
// record.setShopName(wxMerchant.getName()); | |||||
}else{ | |||||
if(StringUtils.isBlank(record.getShopName())){ | |||||
// record.setShopName("第三方门店"); | |||||
record.setMerchantName("未知门店"); | |||||
} | |||||
logger.info("--第三方付款通知消息未找到门店--shopName="+record.getShopName()+"&shopNumber="+record.getShopNumber()); | |||||
} | |||||
WxCUserBasicInfo basicInfo = null; | |||||
Long userId = null; | |||||
try { | |||||
userId = Long.parseLong(record.getUserNumber()); | |||||
} catch (NumberFormatException e) {} | |||||
if(userId != null){ | |||||
basicInfo = wxCUserBasicInfoService.getById(userId, record.getFinalTenantId()); | |||||
} | |||||
if(basicInfo == null && StringUtils.isNotBlank(record.getUserPhone())){ | |||||
basicInfo = wxCUserBasicInfoService.registerByPhone(record, record.getUserPhone(),null,null,null,null); | |||||
} | |||||
if(basicInfo != null){ | |||||
record.setCUserId(basicInfo.getId()); | |||||
record.setCUserNickName(basicInfo.getNickName()); | |||||
record.setCUserPhone(basicInfo.getPhone()); | |||||
}else{ | |||||
logger.error("--第三方付款通知消息未找到会员--userPhone="+record.getUserPhone()+"$userNumer="+record.getId()); | |||||
} | |||||
wxThirdPartyOrdersMapper.insertNoticeOrder(record); | |||||
if(record.getCUserId() == null){ | |||||
redisLock.unlock(lockKey, timeStr); | |||||
return new ResultData(0); | |||||
} | |||||
try { | |||||
wxCouponSendService.sendCouponToUser(EnumCouponSendSendType.B_MICROPAY, record,EnumPayWay.PAY_WAY_NOT_UNPAY_B_MA,EnumPayVersion.NO_VERSION); | |||||
} catch (Exception e) { | |||||
logger.error("支付发券: " + e.getMessage()); | |||||
} | |||||
Integer businessId = EnumBusiness.BUSINESS_ID6.getCode(); | |||||
if(wxMerchant != null){ | |||||
businessId = wxMerchant.getBusinessId(); | |||||
} | |||||
WxCreditHistory creditHistory = new WxCreditHistory(); | |||||
creditHistory.setTenantId(record.getFinalTenantId()); | |||||
creditHistory.setOperatorType(EnumUserType.THIRD_CIRCLE.getCode()); | |||||
creditHistory.setOperatorId(record.getCUserId()); | |||||
creditHistory.setCUserId(record.getCUserId()); | |||||
creditHistory.setCreateDate(now); | |||||
creditHistory.setCouponId(record.getId()); | |||||
creditHistory.setBusinessId(businessId); | |||||
creditHistory.setMerchantId(record.getMerchantId()); | |||||
creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode()); | |||||
creditHistory.setSpend(record.getPayAmount()); | |||||
creditHistory.setChangePurpose(record.getSourceAppName()+"·消费:商户["+record.getMerchantName()+"] ("+record.getPayAmountStr()+"元) "); | |||||
creditHistory = wxCreditHistoryService.saveOrUpdate(creditHistory,record.getTenantId()); | |||||
Integer creditNum = 0; | |||||
if (creditHistory.getCreditNum() != null) { | |||||
creditNum = creditHistory.getCreditNum(); | |||||
} | |||||
if(creditNum == 0){ | |||||
redisLock.unlock(lockKey, timeStr); | |||||
return new ResultData(0); | |||||
} | |||||
record.setIncreasedPoints(creditNum); | |||||
record.setPointsUpdateTime(creditHistory.getCreateDate()); | |||||
this.updatePoints(record); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
return new ResultData(creditNum); | |||||
} | |||||
}else { | |||||
logger.debug("CacheAspect 读库等待中, key:{}: " + lockKey); | |||||
try { | |||||
Thread.sleep(2000); | |||||
} catch (InterruptedException e) { | |||||
e.printStackTrace(); | |||||
}finally { | |||||
redisLock.unlock(lockKey, timeStr); | |||||
} | |||||
return new ResultData(ErrorCode.SYS_REPEAT_SUBMIT_EXCEPTION); | |||||
} | |||||
} | |||||
@Override | |||||
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
public ResultData insertRefundNoticeOrder(WxThirdPartyOrders record) { | |||||
WxThirdPartyOrders order = this.getOrderByTransactionId(EnumThirdOrderType.RMB_PAY,record.getTransactionId(),record.getTenantId()); | |||||
if(order == null){ | |||||
logger.error("--第三方退款--付款消息未找到--transactionId="+record.getTransactionId()); | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "付款消息未找到"); | |||||
}else{ | |||||
String lockKey = StringUtils.join(THIRD_CIRCLE_KEY,record.getRefundId(), ":",EnumYesOrNo.YES.getCode(),":", "lock"); | |||||
long time = System.currentTimeMillis() + 2000; | |||||
String timeStr = String.valueOf(time); | |||||
if (redisLock.lock2(lockKey, timeStr)) { | |||||
WxThirdPartyOrders refundOrder = this.getRefundOrderByRefundId(EnumThirdOrderType.RMB_PAY,record.getRefundId(),record.getTenantId()); | |||||
if(refundOrder != null){ | |||||
logger.error("--第三方退款--退款消息已存在---RefundId="+record.getRefundId()); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "退款数据已存在"); | |||||
}else{ | |||||
List<WxThirdPartyOrders> refundOrders = this.getRefundOrderByTransactionId(EnumThirdOrderType.RMB_PAY,record.getTransactionId(),record.getTenantId()); | |||||
Integer amount = order.getPayAmount(); | |||||
Integer increasedPoints = order.getIncreasedPoints(); | |||||
Integer refundAmount = 0; | |||||
Integer refundIncreasedPoints = 0; | |||||
if(refundOrders != null && refundOrders.size()>0){ | |||||
for (WxThirdPartyOrders ro:refundOrders) { | |||||
refundAmount += ro.getRefundAmount(); | |||||
refundIncreasedPoints += ro.getIncreasedPoints(); | |||||
} | |||||
} | |||||
if(record.getRefundAmount() == null){ | |||||
record.setRefundAmount(order.getPayAmount()-refundAmount); | |||||
} | |||||
if(refundAmount >= amount){ | |||||
logger.error("--第三方退款--已经退款--transactionId="+record.getTransactionId()); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "已经退款"); | |||||
}else if((refundAmount + record.getRefundAmount()) > amount ){ | |||||
logger.error("--第三方退款--退款金额超限--transactionId="+record.getTransactionId()); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
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.RMB_PAY.getCode()); | |||||
record.setShopName(order.getShopName()); | |||||
record.setShopNumber(order.getShopNumber()); | |||||
record.setUserPhone(order.getUserPhone()); | |||||
record.setUserNumber(order.getUserNumber()); | |||||
record.setAmount(order.getAmount()); | |||||
record.setPayAmount(order.getPayAmount()); | |||||
record.setCUserId(order.getCUserId()); | |||||
record.setCUserNickName(order.getCUserNickName()); | |||||
record.setCUserPhone(order.getCUserPhone()); | |||||
record.setMerchantId(order.getMerchantId()); | |||||
record.setMerchantName(order.getMerchantName()); | |||||
wxThirdPartyOrdersMapper.insertRefundNoticeOrder(record); | |||||
if((refundAmount + record.getRefundAmount()) == amount){ | |||||
order.setOrderStatus(2);//全额退款 | |||||
}else{ | |||||
order.setOrderStatus(1);//部分退款 | |||||
} | |||||
order.setUpdateTime(now); | |||||
wxThirdPartyOrdersMapper.updateOrderStatus(order); | |||||
int creditNum = 0; | |||||
if(order.getEarnPoints().equals(EnumYesOrNo.YES.getCode())){ | |||||
WxCreditHistory creditHistory = new WxCreditHistory(); | |||||
creditHistory.setTenantId(record.getFinalTenantId()); | |||||
creditHistory.setOperatorType(EnumUserType.THIRD_CIRCLE.getCode()); | |||||
creditHistory.setOperatorId(record.getCUserId()); | |||||
creditHistory.setCUserId(record.getCUserId()); | |||||
creditHistory.setCreateDate(new Date()); | |||||
creditHistory.setCouponId(record.getId()); | |||||
creditHistory.setMerchantId(record.getMerchantId()); | |||||
creditHistory.setCreditType(EnumScoreType.REFUND_CONSUMPTION.getCode()); | |||||
int points = 0; | |||||
if((refundAmount + record.getRefundAmount()) == amount){ | |||||
points = increasedPoints - refundIncreasedPoints; | |||||
}else{ | |||||
points = new BigDecimal(order.getIncreasedPoints()) | |||||
.divide(new BigDecimal(order.getPayAmount()),2,BigDecimal.ROUND_HALF_UP) | |||||
.multiply(new BigDecimal(record.getRefundAmount())) | |||||
.intValue(); | |||||
} | |||||
creditHistory.setCreditNum(points); | |||||
creditHistory.setSpend(0-record.getRefundAmount()); | |||||
creditHistory.setChangePurpose(record.getSourceAppName()+"·消费退款:商户["+record.getMerchantName()+"] ("+record.getRefundAmountStr()+"元) "); | |||||
creditHistory = wxCreditHistoryService.saveOrUpdate(creditHistory,record.getTenantId()); | |||||
if (creditHistory.getCreditNum() != null) { | |||||
creditNum = creditHistory.getCreditNum(); | |||||
} | |||||
if(creditNum != 0){ | |||||
record.setIncreasedPoints(creditNum); | |||||
record.setPointsUpdateTime(creditHistory.getCreateDate()); | |||||
this.updatePoints(record); | |||||
} | |||||
} | |||||
redisLock.unlock(lockKey, timeStr); | |||||
return new ResultData(creditNum); | |||||
} | |||||
} | |||||
}else { | |||||
logger.debug("CacheAspect 读库等待中, key:{}: " + lockKey); | |||||
try { | |||||
Thread.sleep(2000); | |||||
} catch (InterruptedException e) { | |||||
e.printStackTrace(); | |||||
}finally { | |||||
redisLock.unlock(lockKey, timeStr); | |||||
} | |||||
return new ResultData(ErrorCode.SYS_REPEAT_SUBMIT_EXCEPTION); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
public void updatePoints(WxThirdPartyOrders record) { | |||||
record.setUpdateTime(new Date()); | |||||
wxThirdPartyOrdersMapper.updatePoints(record); | |||||
} | |||||
@Override | |||||
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
public void pointDeduction(WxThirdPartyOrders record) { | |||||
WxCUserBasicInfo basicInfo = null; | |||||
Long userId = null; | |||||
try { | |||||
userId = Long.parseLong(record.getUserNumber()); | |||||
} catch (NumberFormatException e) {} | |||||
if(userId != null){ | |||||
basicInfo = wxCUserBasicInfoService.getById(userId, record.getFinalTenantId()); | |||||
} | |||||
if(basicInfo == null){ | |||||
basicInfo = wxCUserBasicInfoService.registerByPhone(record, record.getUserPhone(),null,null,null,null); | |||||
} | |||||
if(basicInfo == null){ | |||||
logger.error("--第三方积分订单--未找到用户---userId="+record.getUserNumber()); | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未找到用户"); | |||||
} | |||||
record.setCUserId(basicInfo.getId()); | |||||
record.setCUserNickName(basicInfo.getNickName()); | |||||
record.setCUserPhone(basicInfo.getPhone()); | |||||
String lockKey = StringUtils.join(THIRD_CIRCLE_KEY,record.getTransactionId(), ":CP:", "lock"); | |||||
long time = System.currentTimeMillis() + 2000; | |||||
String timeStr = String.valueOf(time); | |||||
if (redisLock.lock2(lockKey, timeStr)) { | |||||
WxThirdPartyOrders byTransactionId = this.getOrderByTransactionId(EnumThirdOrderType.CREDIT_PAY,record.getTransactionId(),record.getTenantId()); | |||||
if(byTransactionId != null){ | |||||
logger.error("--第三方积分订单--数据已存在---byTransactionId="+byTransactionId.getTransactionId()); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
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())); | |||||
WxMerchant wxMerchant = wxMerchantService.getMerchantByEncode(record.getShopNumber()); | |||||
if(wxMerchant != null){ | |||||
record.setMerchantId(wxMerchant.getId()); | |||||
record.setMerchantName(wxMerchant.getName()); | |||||
// record.setShopName(wxMerchant.getName()); | |||||
}else{ | |||||
if(StringUtils.isBlank(record.getShopName())){ | |||||
// record.setShopName("第三方门店"); | |||||
record.setMerchantName("未知门店"); | |||||
} | |||||
logger.info("--第三方积分抵扣未找到门店--shopName="+record.getShopName()+"&shopNumber="+record.getShopNumber()); | |||||
} | |||||
WxCreditHistory creditHistory = new WxCreditHistory(); | |||||
creditHistory.setTenantId(record.getFinalTenantId()); | |||||
creditHistory.setCUserId(basicInfo.getId()); | |||||
creditHistory.setOperatorId(basicInfo.getId()); | |||||
creditHistory.setOperatorType(EnumUserType.THIRD_CIRCLE.getCode()); | |||||
creditHistory.setCreditNum(record.getPayAmount()); | |||||
creditHistory.setCreditType(EnumScoreType.CHANGE_CREDIT.getCode()); | |||||
creditHistory.setChangePurpose(record.getSourceAppName()+"·积分抵扣-"+record.getPayAmount()+"("+record.getSummary()+")"); | |||||
creditHistory.setCouponId(record.getId()); | |||||
creditHistory = wxCreditHistoryService.saveOrUpdate(creditHistory, record.getTenantId()); | |||||
Integer creditNum = 0; | |||||
if (creditHistory.getCreditNum() != null) { | |||||
creditNum = creditHistory.getCreditNum(); | |||||
} | |||||
if(creditNum == 0){ | |||||
redisLock.unlock(lockKey, timeStr); | |||||
throw new MallinkException(ErrorCode.CREDIT_ZERO.getCode(), "本次扣减积分为0"); | |||||
} | |||||
wxThirdPartyOrdersMapper.insertNoticeOrder(record); | |||||
} | |||||
redisLock.unlock(lockKey, timeStr); | |||||
}else{ | |||||
logger.debug("CacheAspect 读库等待中, key:{}: " + lockKey); | |||||
try { | |||||
Thread.sleep(2000); | |||||
} catch (InterruptedException e) { | |||||
e.printStackTrace(); | |||||
}finally { | |||||
redisLock.unlock(lockKey, timeStr); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
public void pointRefund(WxThirdPartyOrders record) { | |||||
WxThirdPartyOrders order = this.getOrderByTransactionId(EnumThirdOrderType.CREDIT_PAY,record.getTransactionId(),record.getTenantId()); | |||||
if(order == null){ | |||||
logger.error("--第三方积分退款--积分付款消息未找到--transactionId="+record.getTransactionId()); | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "积分抵扣订单未找到"); | |||||
}else{ | |||||
String lockKey = StringUtils.join(THIRD_CIRCLE_KEY,record.getRefundId(), ":CPR:", "lock"); | |||||
long time = System.currentTimeMillis() + 2000; | |||||
String timeStr = String.valueOf(time); | |||||
if (redisLock.lock2(lockKey, timeStr)) { | |||||
// WxThirdPartyOrders refundOrder = this.getRefundOrderByRefundId(EnumThirdOrderType.CREDIT_PAY,record.getRefundId(),record.getTenantId()); | |||||
// if(refundOrder != null){ | |||||
// logger.error("--第三方积分退款--退款消息已存在---RefundId="+record.getRefundId()); | |||||
// redisLock.unlock(lockKey, timeStr); | |||||
// throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "退款数据已存在"); | |||||
// }else{ | |||||
List<WxThirdPartyOrders> refundOrders = this.getRefundOrderByTransactionId(EnumThirdOrderType.CREDIT_PAY,record.getTransactionId(),record.getTenantId()); | |||||
if(refundOrders != null && refundOrders.size()>0){ | |||||
logger.error("--第三方积分退款--已经退款--transactionId="+record.getTransactionId()); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
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()); | |||||
record.setRefundAmount(order.getPayAmount()); | |||||
record.setShopName(order.getShopName()); | |||||
record.setShopNumber(order.getShopNumber()); | |||||
record.setUserPhone(order.getUserPhone()); | |||||
record.setUserNumber(order.getUserNumber()); | |||||
record.setAmount(order.getAmount()); | |||||
record.setPayAmount(order.getPayAmount()); | |||||
record.setCUserId(order.getCUserId()); | |||||
record.setCUserNickName(order.getCUserNickName()); | |||||
record.setCUserPhone(order.getCUserPhone()); | |||||
record.setMerchantId(order.getMerchantId()); | |||||
record.setMerchantName(order.getMerchantName()); | |||||
wxThirdPartyOrdersMapper.insertRefundNoticeOrder(record); | |||||
order.setOrderStatus(2);//全额退款 | |||||
order.setUpdateTime(now); | |||||
wxThirdPartyOrdersMapper.updateOrderStatus(order); | |||||
int creditNum = 0; | |||||
// if(order.getEarnPoints().equals(EnumYesOrNo.YES.getCode())){ | |||||
WxCreditHistory creditHistory = new WxCreditHistory(); | |||||
creditHistory.setTenantId(record.getFinalTenantId()); | |||||
creditHistory.setOperatorType(EnumUserType.THIRD_CIRCLE.getCode()); | |||||
creditHistory.setOperatorId(record.getCUserId()); | |||||
creditHistory.setCUserId(record.getCUserId()); | |||||
creditHistory.setCreateDate(new Date()); | |||||
creditHistory.setCouponId(record.getId()); | |||||
creditHistory.setMerchantId(record.getMerchantId()); | |||||
creditHistory.setCreditType(EnumScoreType.REFUND_REDUCE_CREDIT.getCode()); | |||||
creditHistory.setCreditNum(record.getRefundAmount()); | |||||
creditHistory.setSpend(0-record.getRefundAmount()); | |||||
creditHistory.setChangePurpose(record.getSourceAppName()+"·积分抵扣退款:商户["+record.getMerchantName()+"] (-"+record.getRefundAmount()+") "); | |||||
creditHistory = wxCreditHistoryService.saveOrUpdate(creditHistory,record.getTenantId()); | |||||
if (creditHistory.getCreditNum() != null) { | |||||
creditNum = creditHistory.getCreditNum(); | |||||
} | |||||
if(creditNum != 0){ | |||||
record.setIncreasedPoints(creditNum); | |||||
record.setPointsUpdateTime(creditHistory.getCreateDate()); | |||||
this.updatePoints(record); | |||||
} | |||||
// } | |||||
redisLock.unlock(lockKey, timeStr); | |||||
// return new ResultData(creditNum); | |||||
} | |||||
// } | |||||
}else { | |||||
logger.debug("CacheAspect 读库等待中, key:{}: " + lockKey); | |||||
try { | |||||
Thread.sleep(2000); | |||||
} catch (InterruptedException e) { | |||||
e.printStackTrace(); | |||||
}finally { | |||||
redisLock.unlock(lockKey, timeStr); | |||||
} | |||||
// return new ResultData(ErrorCode.SYS_REPEAT_SUBMIT_EXCEPTION); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
public void pointChange(WxThirdPartyOrders record) { | |||||
WxCUserBasicInfo basicInfo = null; | |||||
Long userId = null; | |||||
try { | |||||
userId = Long.parseLong(record.getUserNumber()); | |||||
} catch (NumberFormatException e) {} | |||||
if(userId != null){ | |||||
basicInfo = wxCUserBasicInfoService.getById(userId, record.getFinalTenantId()); | |||||
} | |||||
if(basicInfo == null){ | |||||
basicInfo = wxCUserBasicInfoService.registerByPhone(record, record.getUserPhone(),null,null,null,null); | |||||
} | |||||
if(basicInfo == null){ | |||||
logger.error("--第三方积分变动--未找到用户---userId="+record.getUserNumber()); | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未找到用户"); | |||||
} | |||||
record.setCUserId(basicInfo.getId()); | |||||
record.setCUserNickName(basicInfo.getNickName()); | |||||
record.setCUserPhone(basicInfo.getPhone()); | |||||
String lockKey = StringUtils.join(THIRD_CIRCLE_KEY,record.getTransactionId(), ":PACC:", "lock"); | |||||
long time = System.currentTimeMillis() + 2000; | |||||
String timeStr = String.valueOf(time); | |||||
if (redisLock.lock2(lockKey, timeStr)) { | |||||
WxThirdPartyOrders byTransactionId = this.getOrderByTransactionId(EnumThirdOrderType.CREDIT_CHANGE,record.getTransactionId(),record.getTenantId()); | |||||
if(byTransactionId != null){ | |||||
logger.error("--第三方积分变动--数据已存在---byTransactionId="+byTransactionId.getTransactionId()); | |||||
redisLock.unlock(lockKey, timeStr); | |||||
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_CHANGE.getCode()); | |||||
WxCreditHistory creditHistory = new WxCreditHistory(); | |||||
creditHistory.setTenantId(record.getFinalTenantId()); | |||||
creditHistory.setCUserId(basicInfo.getId()); | |||||
creditHistory.setOperatorId(basicInfo.getId()); | |||||
creditHistory.setOperatorType(EnumUserType.THIRD_CIRCLE.getCode()); | |||||
creditHistory.setCreditNum(record.getPayAmount()); | |||||
creditHistory.setCreditType(EnumScoreType.POINT_CHANGE.getCode()); | |||||
if(creditHistory.getCreditNum() > 0){ | |||||
creditHistory.setChangePurpose(record.getSourceAppName()+"·积分新增"+record.getPayAmount()+"("+record.getSummary()+")"); | |||||
}else if(creditHistory.getCreditNum() < 0){ | |||||
creditHistory.setChangePurpose(record.getSourceAppName()+"·积分扣减"+record.getPayAmount()+"("+record.getSummary()+")"); | |||||
} | |||||
creditHistory.setCouponId(record.getId()); | |||||
creditHistory = wxCreditHistoryService.saveOrUpdate(creditHistory, record.getTenantId()); | |||||
Integer creditNum = 0; | |||||
if (creditHistory.getCreditNum() != null) { | |||||
creditNum = creditHistory.getCreditNum(); | |||||
} | |||||
if(creditNum == 0){ | |||||
redisLock.unlock(lockKey, timeStr); | |||||
throw new MallinkException(ErrorCode.CREDIT_ZERO.getCode(), "本次扣减积分为0"); | |||||
} | |||||
wxThirdPartyOrdersMapper.insertNoticeOrder(record); | |||||
} | |||||
redisLock.unlock(lockKey, timeStr); | |||||
}else{ | |||||
logger.debug("CacheAspect 读库等待中, key:{}: " + lockKey); | |||||
try { | |||||
Thread.sleep(2000); | |||||
} catch (InterruptedException e) { | |||||
e.printStackTrace(); | |||||
}finally { | |||||
redisLock.unlock(lockKey, timeStr); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
public void exportData(WxThirdPartyOrders circleOrder, HttpServletRequest request, HttpServletResponse response) { | |||||
List<WxThirdPartyOrders> list = wxThirdPartyOrdersMapper.findList(circleOrder); | |||||
excelService.exportExcel(list, null, "第三方订单交易", WxThirdPartyOrders.class, "第三方订单交易.xlsx", response, false); | |||||
} | |||||
@Override | |||||
public void exportDataVo(WxThirdPartyOrders circleOrder, HttpServletRequest request, HttpServletResponse response) { | |||||
List<WxThirdPartyOrdersVo> list = wxThirdPartyOrdersMapper.findListVo(circleOrder); | |||||
excelService.exportExcel(list, null, "第三方积分抵扣", WxThirdPartyOrdersVo.class, "第三方积分抵扣.xlsx", response, false); | |||||
} | |||||
@Override | |||||
public Integer sumCirclePayment(BusinessCircleBase circleOrder) { | |||||
Integer sumCirclePayment = wxThirdPartyOrdersMapper.sumCirclePayment(circleOrder); | |||||
return sumCirclePayment==null?0:sumCirclePayment; | |||||
} | |||||
@Override | |||||
public Integer sumCircleRefundAmount(BusinessCircleBase circleOrder) { | |||||
Integer sumCircleRefundAmount = wxThirdPartyOrdersMapper.sumCircleRefundAmount(circleOrder); | |||||
return sumCircleRefundAmount==null?0:sumCircleRefundAmount; | |||||
} | |||||
} |
@@ -1,58 +0,0 @@ | |||||
package com.iformall.service.msg.impl; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.domain.po.*; | |||||
import com.iformall.domain.po.base.TenantEntity; | |||||
import com.iformall.domain.po.msg.AfterBusinessCreditMsg; | |||||
import com.iformall.domain.po.msg.AfterCarInOutMsg; | |||||
import com.iformall.domain.po.msg.BaseMsg; | |||||
import com.iformall.enums.EnumAppPlat; | |||||
import com.iformall.enums.EnumBusinessType; | |||||
import com.iformall.enums.EnumCarCmd; | |||||
import com.iformall.mapper.WxCUserMapper; | |||||
import com.iformall.mapper.WxCarCmdLogMapper; | |||||
import com.iformall.pay.WxPayConstant; | |||||
import com.iformall.service.WxAppinfoService; | |||||
import com.iformall.service.WxBusinessCircleOrderService; | |||||
import com.iformall.service.WxCUserCarService; | |||||
import com.iformall.service.WxPayAccountService; | |||||
import com.iformall.service.msg.MsgSendService; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
/** | |||||
* | |||||
*/ | |||||
@Service | |||||
public class AfterBusinessCreditMsgServiceImpl implements MsgSendService { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Autowired | |||||
private WxBusinessCircleOrderService wxBusinessCircleOrderService; | |||||
@Override | |||||
public void send(BaseMsg baseMsg) throws Exception{ | |||||
AfterBusinessCreditMsg msg = (AfterBusinessCreditMsg)baseMsg; | |||||
TenantEntity tenantEntity = new TenantEntity(); | |||||
tenantEntity.setTenantId(msg.getTenantId()); | |||||
tenantEntity.setParentTenantId(msg.getParentTenantId()); | |||||
try { | |||||
Thread.currentThread().sleep(3000); | |||||
} catch (Exception e) { | |||||
logger.error("sleep error: " + e.getMessage()); | |||||
} | |||||
WxBusinessCircleOrder circleOrder = wxBusinessCircleOrderService.getById(msg.getBusinessCircleOrderId(), tenantEntity.getTenantId()); | |||||
if(circleOrder != null){ | |||||
wxBusinessCircleOrderService.notifyPoints(circleOrder); | |||||
} | |||||
} | |||||
} |
@@ -35,9 +35,6 @@ public class AfterCarInOutMsgServiceImpl implements MsgSendService { | |||||
@Autowired | @Autowired | ||||
private WxPayAccountService wxPayAccountService; | private WxPayAccountService wxPayAccountService; | ||||
@Autowired | |||||
private WxBusinessCircleOrderService wxBusinessCircleOrderService; | |||||
@Autowired | @Autowired | ||||
private WxCUserCarService wxCUserCarService; | private WxCUserCarService wxCUserCarService; | ||||
@@ -102,9 +99,6 @@ public class AfterCarInOutMsgServiceImpl implements MsgSendService { | |||||
logger.error("车牌未找到用户{}"+plateNumber); | logger.error("车牌未找到用户{}"+plateNumber); | ||||
return; | return; | ||||
} | } | ||||
ResultData resultData = wxBusinessCircleOrderService.syncParkings(tenantEntity, openId, plateNumber, state, wxCarCmdLog.getCreateDate()); | |||||
logger.info(tenantEntity.getTenantId()+"--"+plateNumber+"--微信商圈同步停车记录{}"+resultData.message); | |||||
} | } | ||||
} | } |
@@ -1,232 +0,0 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
<mapper namespace="com.iformall.mapper.AliBusinessCircleOrderMapper"> | |||||
<resultMap id="BaseResultMap" type="com.iformall.domain.po.AliBusinessCircleOrder"> | |||||
<id column="id" jdbcType="BIGINT" property="id"/> | |||||
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||||
<result column="notice_id" jdbcType="VARCHAR" property="noticeId" /> | |||||
<result column="notice_create_time" jdbcType="TIMESTAMP" property="noticeCreateTime"/> | |||||
<result column="notice_event_type" jdbcType="VARCHAR" property="noticeEventType" /> | |||||
<result column="summary" jdbcType="VARCHAR" property="summary" /> | |||||
<result column="mall_id" jdbcType="VARCHAR" property="mallId" /> | |||||
<result column="mall_name" jdbcType="VARCHAR" property="mallName" /> | |||||
<result column="mall_store_id" jdbcType="VARCHAR" property="mallStoreId" /> | |||||
<result column="buyer_id" jdbcType="VARCHAR" property="buyerId" /> | |||||
<result column="time_end" jdbcType="TIMESTAMP" property="timeEnd"/> | |||||
<result column="amount" jdbcType="INTEGER" property="amount"/> | |||||
<result column="pay_amount" jdbcType="INTEGER" property="payAmount"/> | |||||
<result column="transaction_id" jdbcType="VARCHAR" property="transactionId" /> | |||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> | |||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> | |||||
<result column="merchant_id" jdbcType="BIGINT" property="merchantId"/> | |||||
<result column="merchant_name" jdbcType="VARCHAR" property="merchantName" /> | |||||
<result column="c_user_id" jdbcType="BIGINT" property="cUserId"/> | |||||
<result column="c_user_nick_name" jdbcType="VARCHAR" property="cUserNickName" /> | |||||
<result column="c_user_phone" jdbcType="VARCHAR" property="cUserPhone" /> | |||||
<result column="earn_points" jdbcType="TINYINT" property="earnPoints"/> | |||||
<result column="increased_points" jdbcType="INTEGER" property="increasedPoints"/> | |||||
<result column="points_update_time" jdbcType="TIMESTAMP" property="pointsUpdateTime"/> | |||||
<result column="is_refund" jdbcType="TINYINT" property="isRefund"/> | |||||
<result column="order_status" jdbcType="TINYINT" property="orderStatus"/> | |||||
<result column="refund_id" jdbcType="VARCHAR" property="refundId" /> | |||||
<result column="refund_amount" jdbcType="INTEGER" property="refundAmount"/> | |||||
</resultMap> | |||||
<sql id="allColumns"> | |||||
`id`, `tenant_id`, `parent_tenant_id`, `notice_id`, `notice_create_time`, `notice_event_type`, | |||||
`summary`,`mall_id`, `mall_name`, `mall_store_id`, `buyer_id`, | |||||
`time_end`, `amount`, `pay_amount`, `transaction_id`, `create_time`, `update_time`, | |||||
`merchant_id`,`merchant_name`, `c_user_id`, `c_user_nick_name`, `c_user_phone`, | |||||
`earn_points`, `increased_points`, `points_update_time`, | |||||
`is_refund`, `order_status`, `refund_id`, `refund_amount` | |||||
</sql> | |||||
<sql id="dynamicWhereConditions"> | |||||
where 1 = 1 | |||||
<if test=" null != id "> | |||||
and `id` = #{id} | |||||
</if> | |||||
<if test=" null != tenantId and '' != tenantId"> | |||||
and `tenant_id` = #{tenantId} | |||||
</if> | |||||
<if test=" null != parentTenantId and '' != parentTenantId"> | |||||
and `parent_tenant_id` = #{parentTenantId} | |||||
</if> | |||||
<if test=" null != mallStoreId and '' != mallStoreId"> | |||||
and `mall_store_id` = #{mallStoreId} | |||||
</if> | |||||
<if test=" null != buyerId and '' != buyerId"> | |||||
and `buyer_id` = #{buyerId} | |||||
</if> | |||||
<if test=" null != noticeId and '' != noticeId"> | |||||
and `notice_id` = #{noticeId} | |||||
</if> | |||||
<if test=" null != startTime "> | |||||
and `time_end` >= #{startTime} | |||||
</if> | |||||
<if test=" null != endTime"> | |||||
and `time_end` < #{endTime} | |||||
</if> | |||||
<if test=" null != transactionId and '' != transactionId"> | |||||
and `transaction_id` = #{transactionId} | |||||
</if> | |||||
<if test=" null != merchantId "> | |||||
and `merchant_id` = #{merchantId} | |||||
</if> | |||||
<if test=" null != merchantName and ''!=merchantName"> | |||||
and `merchant_name` like concat('%', #{merchantName},'%') | |||||
</if> | |||||
<if test=" null != cUserId "> | |||||
and `c_user_id` = #{cUserId} | |||||
</if> | |||||
<if test=" null != cUserNickName and ''!=cUserNickName"> | |||||
and `c_user_nick_name` like concat('%', #{cUserNickName},'%') | |||||
</if> | |||||
<if test=" null != cUserPhone and ''!=cUserPhone"> | |||||
and `c_user_phone` like concat('%', #{cUserPhone},'%') | |||||
</if> | |||||
<if test=" null != earnPoints "> | |||||
and `earn_points` = #{earnPoints} | |||||
</if> | |||||
<if test=" null != isRefund "> | |||||
and `is_refund` = #{isRefund} | |||||
</if> | |||||
<if test=" null != orderStatus "> | |||||
and `order_status` = #{orderStatus} | |||||
</if> | |||||
<if test=" null != refundId and '' != refundId"> | |||||
and `refund_id` = #{refundId} | |||||
</if> | |||||
<if test=" null != ids "> | |||||
and `id` in | |||||
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
#{idItem} | |||||
</foreach> | |||||
</if> | |||||
</sql> | |||||
<select id="findList" parameterType="com.iformall.domain.po.AliBusinessCircleOrder" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from ali_business_circle_order | |||||
<include refid="dynamicWhereConditions"/> | |||||
<if test=" null != sortColumns">order by ${sortColumns}</if> | |||||
</select> | |||||
<select id="getById" parameterType="com.iformall.domain.po.AliBusinessCircleOrder" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from ali_business_circle_order | |||||
where `id` = #{id} | |||||
and tenant_id=#{tenantId} | |||||
</select> | |||||
<select id="getOrderByTransactionId" parameterType="com.iformall.domain.po.AliBusinessCircleOrder" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from ali_business_circle_order | |||||
where `is_refund` = 0 | |||||
and tenant_id = #{tenantId} | |||||
and `transaction_id` = #{transactionId} | |||||
</select> | |||||
<select id="getRefundOrderByRefundId" parameterType="com.iformall.domain.po.AliBusinessCircleOrder" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from ali_business_circle_order | |||||
where `is_refund` = 1 | |||||
and tenant_id = #{tenantId} | |||||
and `refund_id` = #{refundId} | |||||
</select> | |||||
<select id="getRefundOrderByTransactionId" parameterType="com.iformall.domain.po.AliBusinessCircleOrder" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from ali_business_circle_order | |||||
where `is_refund` = 1 | |||||
and tenant_id = #{tenantId} | |||||
and `transaction_id` = #{transactionId} | |||||
</select> | |||||
<insert id="insertNoticeOrder" parameterType="com.iformall.domain.po.AliBusinessCircleOrder" > | |||||
INSERT INTO ali_business_circle_order ( | |||||
`id`, `tenant_id`, `parent_tenant_id`, `notice_id`, `notice_create_time`, `notice_event_type`, | |||||
`summary`, `mall_id`, `mall_name`, `mall_store_id`, `buyer_id`,`time_end`, `amount`, `pay_amount`, `transaction_id`, `create_time`, `update_time`, | |||||
`merchant_id`,`merchant_name`, `c_user_id`, `c_user_nick_name`, `c_user_phone`, `earn_points`, `is_refund` | |||||
) | |||||
VALUES( | |||||
#{id},#{tenantId},#{parentTenantId},#{noticeId},#{noticeCreateTime},#{noticeEventType}, | |||||
#{summary},#{mallId},#{mallName},#{mallStoreId},#{buyerId},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{createTime},#{updateTime}, | |||||
#{merchantId},#{merchantName},#{cUserId},#{cUserNickName},#{cUserPhone},0,0 | |||||
); | |||||
</insert> | |||||
<update id="updatePoints" parameterType="com.iformall.domain.po.AliBusinessCircleOrder"> | |||||
update ali_business_circle_order set | |||||
`earn_points` = 1, `increased_points` = #{increasedPoints}, `points_update_time` = #{pointsUpdateTime}, | |||||
`update_time` = #{updateTime} | |||||
where `id` = #{id} and `tenant_id` = #{tenantId} | |||||
</update> | |||||
<insert id="insertRefundNoticeOrder" parameterType="com.iformall.domain.po.AliBusinessCircleOrder" > | |||||
INSERT INTO ali_business_circle_order ( | |||||
`id`, `tenant_id`, `parent_tenant_id`,`notice_id`, `notice_create_time`, `notice_event_type`, | |||||
`summary`,`mall_id`, `mall_name`, `mall_store_id`, `buyer_id`, `time_end`, `amount`,`pay_amount`, `transaction_id`, `create_time`, `update_time`, | |||||
`merchant_id`,`merchant_name`, `c_user_id`, `c_user_nick_name`, `c_user_phone`, `earn_points`, `is_refund`, `refund_id`, `refund_amount` | |||||
) | |||||
VALUES( | |||||
#{id},#{tenantId},#{parentTenantId},#{noticeId},#{noticeCreateTime},#{noticeEventType}, | |||||
#{summary},#{mallId},#{mallName},#{mallStoreId},#{buyerId},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{createTime},#{updateTime}, | |||||
#{merchantId},#{merchantName},#{cUserId},#{cUserNickName},#{cUserPhone},0,1,#{refundId},#{refundAmount} | |||||
); | |||||
</insert> | |||||
<update id="updateOrderStatus" parameterType="com.iformall.domain.po.AliBusinessCircleOrder"> | |||||
update ali_business_circle_order set | |||||
`order_status` = #{orderStatus}, | |||||
`update_time` = #{updateTime} | |||||
where `id` = #{id} and `tenant_id` = #{tenantId} | |||||
</update> | |||||
<select id="sumCirclePayment" parameterType="com.iformall.domain.po.BusinessCircleBase" resultType="Integer"> | |||||
select | |||||
IFNULL(SUM(`pay_amount`),0) as sum_pay_amount | |||||
from ali_business_circle_order | |||||
<include refid="dynamicWhereConditions"/> | |||||
and is_refund = 0 | |||||
</select> | |||||
<select id="sumCircleRefundAmount" parameterType="com.iformall.domain.po.BusinessCircleBase" resultType="Integer"> | |||||
select | |||||
IFNULL(SUM(`refund_amount`),0) as sum_refund_amount | |||||
from ali_business_circle_order | |||||
<include refid="dynamicWhereConditions"/> | |||||
and is_refund = 1 | |||||
</select> | |||||
</mapper> |
@@ -1,264 +0,0 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
<mapper namespace="com.iformall.mapper.WxBusinessCircleOrderMapper"> | |||||
<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBusinessCircleOrder"> | |||||
<id column="id" jdbcType="BIGINT" property="id"/> | |||||
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||||
<result column="notice_id" jdbcType="VARCHAR" property="noticeId" /> | |||||
<result column="notice_create_time" jdbcType="TIMESTAMP" property="noticeCreateTime"/> | |||||
<result column="notice_event_type" jdbcType="VARCHAR" property="noticeEventType" /> | |||||
<result column="summary" jdbcType="VARCHAR" property="summary" /> | |||||
<result column="wx_mchid" jdbcType="VARCHAR" property="wxMchid" /> | |||||
<result column="wx_merchant_name" jdbcType="VARCHAR" property="wxMerchantName" /> | |||||
<result column="wx_shop_name" jdbcType="VARCHAR" property="wxShopName" /> | |||||
<result column="wx_shop_number" jdbcType="VARCHAR" property="wxShopNumber" /> | |||||
<result column="appid" jdbcType="VARCHAR" property="appid" /> | |||||
<result column="openid" jdbcType="VARCHAR" property="openid" /> | |||||
<result column="time_end" jdbcType="TIMESTAMP" property="timeEnd"/> | |||||
<result column="amount" jdbcType="INTEGER" property="amount"/> | |||||
<result column="pay_amount" jdbcType="INTEGER" property="payAmount"/> | |||||
<result column="transaction_id" jdbcType="VARCHAR" property="transactionId" /> | |||||
<result column="commit_tag" jdbcType="VARCHAR" property="commitTag" /> | |||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> | |||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> | |||||
<result column="merchant_id" jdbcType="BIGINT" property="merchantId"/> | |||||
<result column="merchant_name" jdbcType="VARCHAR" property="merchantName" /> | |||||
<result column="c_user_id" jdbcType="BIGINT" property="cUserId"/> | |||||
<result column="c_user_nick_name" jdbcType="VARCHAR" property="cUserNickName" /> | |||||
<result column="c_user_phone" jdbcType="VARCHAR" property="cUserPhone" /> | |||||
<result column="earn_points" jdbcType="TINYINT" property="earnPoints"/> | |||||
<result column="increased_points" jdbcType="INTEGER" property="increasedPoints"/> | |||||
<result column="points_update_time" jdbcType="TIMESTAMP" property="pointsUpdateTime"/> | |||||
<result column="is_points_notify" jdbcType="TINYINT" property="isPointsNotify"/> | |||||
<result column="is_refund" jdbcType="TINYINT" property="isRefund"/> | |||||
<result column="order_status" jdbcType="TINYINT" property="orderStatus"/> | |||||
<result column="refund_id" jdbcType="VARCHAR" property="refundId" /> | |||||
<result column="refund_amount" jdbcType="INTEGER" property="refundAmount"/> | |||||
</resultMap> | |||||
<sql id="allColumns"> | |||||
`id`, `tenant_id`, `parent_tenant_id`, `notice_id`, `notice_create_time`, `notice_event_type`, | |||||
`summary`, `wx_mchid`, `wx_merchant_name`, `wx_shop_name`, `wx_shop_number`, | |||||
`appid`, `openid`, `time_end`, `amount`, `pay_amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`, | |||||
`merchant_id`,`merchant_name`, `c_user_id`, `c_user_nick_name`, `c_user_phone`, | |||||
`earn_points`, `increased_points`, `points_update_time`, `is_points_notify`, | |||||
`is_refund`, `order_status`, `refund_id`, `refund_amount` | |||||
</sql> | |||||
<sql id="dynamicWhereConditions"> | |||||
where 1 = 1 | |||||
<if test=" null != id "> | |||||
and `id` = #{id} | |||||
</if> | |||||
<if test=" null != tenantId and '' != tenantId"> | |||||
and `tenant_id` = #{tenantId} | |||||
</if> | |||||
<if test=" null != parentTenantId and '' != parentTenantId"> | |||||
and `parent_tenant_id` = #{parentTenantId} | |||||
</if> | |||||
<if test=" null != noticeId and '' != noticeId"> | |||||
and `notice_id` = #{noticeId} | |||||
</if> | |||||
<if test=" null != wxMchid and '' != wxMchid"> | |||||
and `wx_mchid` = #{wxMchid} | |||||
</if> | |||||
<if test=" null != wxMerchantName "> | |||||
and `wx_merchant_name` like concat('%', #{wxMerchantName},'%') | |||||
</if> | |||||
<if test=" null != wxShopName "> | |||||
and `wx_shop_name` like concat('%', #{wxShopName},'%') | |||||
</if> | |||||
<if test=" null != wxShopNumber and '' != wxShopNumber"> | |||||
and `wx_shop_number` = #{wxShopNumber} | |||||
</if> | |||||
<if test=" null != appid and '' != appid"> | |||||
and `appid` = #{appid} | |||||
</if> | |||||
<if test=" null != openid and '' != openid"> | |||||
and `openid` = #{openid} | |||||
</if> | |||||
<if test=" null != startTime "> | |||||
and `time_end` >= #{startTime} | |||||
</if> | |||||
<if test=" null != endTime"> | |||||
and `time_end` < #{endTime} | |||||
</if> | |||||
<if test=" null != transactionId and '' != transactionId"> | |||||
and `transaction_id` = #{transactionId} | |||||
</if> | |||||
<if test=" null != merchantId "> | |||||
and `merchant_id` = #{merchantId} | |||||
</if> | |||||
<if test=" null != merchantName and ''!=merchantName"> | |||||
and `merchant_name` like concat('%', #{merchantName},'%') | |||||
</if> | |||||
<if test=" null != cUserId "> | |||||
and `c_user_id` = #{cUserId} | |||||
</if> | |||||
<if test=" null != cUserNickName and ''!=cUserNickName"> | |||||
and `c_user_nick_name` like concat('%', #{cUserNickName},'%') | |||||
</if> | |||||
<if test=" null != cUserPhone and ''!=cUserPhone"> | |||||
and `c_user_phone` like concat('%', #{cUserPhone},'%') | |||||
</if> | |||||
<if test=" null != earnPoints "> | |||||
and `earn_points` = #{earnPoints} | |||||
</if> | |||||
<if test=" null != isPointsNotify "> | |||||
and `is_points_notify` = #{isPointsNotify} | |||||
</if> | |||||
<if test=" null != isRefund "> | |||||
and `is_refund` = #{isRefund} | |||||
</if> | |||||
<if test=" null != orderStatus "> | |||||
and `order_status` = #{orderStatus} | |||||
</if> | |||||
<if test=" null != refundId and '' != refundId"> | |||||
and `refund_id` = #{refundId} | |||||
</if> | |||||
<if test=" null != ids "> | |||||
and `id` in | |||||
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
#{idItem} | |||||
</foreach> | |||||
</if> | |||||
</sql> | |||||
<select id="findList" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from wx_business_circle_order | |||||
<include refid="dynamicWhereConditions"/> | |||||
<if test=" null != sortColumns">order by ${sortColumns}</if> | |||||
</select> | |||||
<select id="getById" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from wx_business_circle_order | |||||
where `id` = #{id} | |||||
and tenant_id=#{tenantId} | |||||
</select> | |||||
<select id="getOrderByTransactionId" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from wx_business_circle_order | |||||
where `is_refund` = 0 | |||||
and tenant_id = #{tenantId} | |||||
and `transaction_id` = #{transactionId} | |||||
</select> | |||||
<select id="getRefundOrderByRefundId" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from wx_business_circle_order | |||||
where `is_refund` = 1 | |||||
and tenant_id = #{tenantId} | |||||
and `refund_id` = #{refundId} | |||||
</select> | |||||
<select id="getRefundOrderByTransactionId" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from wx_business_circle_order | |||||
where `is_refund` = 1 | |||||
and tenant_id = #{tenantId} | |||||
and `transaction_id` = #{transactionId} | |||||
</select> | |||||
<insert id="insertNoticeOrder" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" > | |||||
INSERT INTO wx_business_circle_order ( | |||||
`id`, `tenant_id`, `parent_tenant_id`, `notice_id`, `notice_create_time`, `notice_event_type`, | |||||
`summary`, `wx_mchid`, `wx_merchant_name`, `wx_shop_name`, `wx_shop_number`, | |||||
`appid`, `openid`, `time_end`, `amount`, `pay_amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`, | |||||
`merchant_id`,`merchant_name`, `c_user_id`, `c_user_nick_name`, `c_user_phone`, `earn_points`, `is_points_notify`, `is_refund` | |||||
) | |||||
VALUES( | |||||
#{id},#{tenantId},#{parentTenantId},#{noticeId},#{noticeCreateTime},#{noticeEventType}, | |||||
#{summary},#{wxMchid},#{wxMerchantName},#{wxShopName},#{wxShopNumber}, | |||||
#{appid},#{openid},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{commitTag},#{createTime},#{updateTime}, | |||||
#{merchantId},#{merchantName},#{cUserId},#{cUserNickName},#{cUserPhone},0,0,0 | |||||
); | |||||
</insert> | |||||
<update id="updatePoints" parameterType="com.iformall.domain.po.WxBusinessCircleOrder"> | |||||
update wx_business_circle_order set | |||||
`earn_points` = 1, `increased_points` = #{increasedPoints}, `points_update_time` = #{pointsUpdateTime}, | |||||
`update_time` = #{updateTime} | |||||
where `id` = #{id} and `tenant_id` = #{tenantId} | |||||
</update> | |||||
<update id="updateIsPointsNotify" parameterType="com.iformall.domain.po.WxBusinessCircleOrder"> | |||||
update wx_business_circle_order set | |||||
`is_points_notify` = 1, `update_time` = #{updateTime} | |||||
where `id` = #{id} and `tenant_id` = #{tenantId} | |||||
</update> | |||||
<insert id="insertRefundNoticeOrder" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" > | |||||
INSERT INTO wx_business_circle_order ( | |||||
`id`, `tenant_id`, `parent_tenant_id`, `notice_id`, `notice_create_time`, `notice_event_type`, | |||||
`summary`, `wx_mchid`, `wx_merchant_name`, `wx_shop_name`, `wx_shop_number`, | |||||
`appid`, `openid`, `time_end`, `amount`,`pay_amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`, | |||||
`merchant_id`,`merchant_name`, `c_user_id`, `c_user_nick_name`, `c_user_phone`, `earn_points`, `is_refund`, `refund_id`, `refund_amount` | |||||
) | |||||
VALUES( | |||||
#{id},#{tenantId},#{parentTenantId},#{noticeId},#{noticeCreateTime},#{noticeEventType}, | |||||
#{summary},#{wxMchid},#{wxMerchantName},#{wxShopName},#{wxShopNumber}, | |||||
#{appid},#{openid},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{commitTag},#{createTime},#{updateTime}, | |||||
#{merchantId},#{merchantName},#{cUserId},#{cUserNickName},#{cUserPhone},0,1,#{refundId},#{refundAmount} | |||||
); | |||||
</insert> | |||||
<update id="updateOrderStatus" parameterType="com.iformall.domain.po.WxBusinessCircleOrder"> | |||||
update wx_business_circle_order set | |||||
`order_status` = #{orderStatus}, | |||||
`update_time` = #{updateTime} | |||||
where `id` = #{id} and `tenant_id` = #{tenantId} | |||||
</update> | |||||
<select id="sumCirclePayment" parameterType="com.iformall.domain.po.BusinessCircleBase" resultType="Integer"> | |||||
select | |||||
IFNULL(SUM(`pay_amount`),0) as sum_pay_amount | |||||
from wx_business_circle_order | |||||
<include refid="dynamicWhereConditions"/> | |||||
and is_refund = 0 | |||||
</select> | |||||
<select id="sumCircleRefundAmount" parameterType="com.iformall.domain.po.BusinessCircleBase" resultType="Integer"> | |||||
select | |||||
IFNULL(SUM(`refund_amount`),0) as sum_refund_amount | |||||
from wx_business_circle_order | |||||
<include refid="dynamicWhereConditions"/> | |||||
and is_refund = 1 | |||||
</select> | |||||
</mapper> |
@@ -1,262 +0,0 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
<mapper namespace="com.iformall.mapper.WxThirdPartyOrdersMapper"> | |||||
<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxThirdPartyOrders"> | |||||
<id column="id" jdbcType="BIGINT" property="id"/> | |||||
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||||
<result column="source_app_id" jdbcType="VARCHAR" property="sourceAppId"/> | |||||
<result column="source_type" jdbcType="INTEGER" property="sourceType"/> | |||||
<result column="notice_id" jdbcType="VARCHAR" property="noticeId" /> | |||||
<result column="notice_create_time" jdbcType="TIMESTAMP" property="noticeCreateTime"/> | |||||
<result column="notice_event_type" jdbcType="VARCHAR" property="noticeEventType" /> | |||||
<result column="summary" jdbcType="VARCHAR" property="summary" /> | |||||
<result column="shop_name" jdbcType="VARCHAR" property="shopName" /> | |||||
<result column="shop_number" jdbcType="VARCHAR" property="shopNumber" /> | |||||
<result column="user_phone" jdbcType="VARCHAR" property="userPhone" /> | |||||
<result column="user_number" jdbcType="VARCHAR" property="userNumber" /> | |||||
<result column="time_end" jdbcType="TIMESTAMP" property="timeEnd"/> | |||||
<result column="amount" jdbcType="INTEGER" property="amount"/> | |||||
<result column="pay_amount" jdbcType="INTEGER" property="payAmount"/> | |||||
<result column="transaction_id" jdbcType="VARCHAR" property="transactionId" /> | |||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> | |||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> | |||||
<result column="merchant_id" jdbcType="BIGINT" property="merchantId"/> | |||||
<result column="merchant_name" jdbcType="VARCHAR" property="merchantName" /> | |||||
<result column="c_user_id" jdbcType="BIGINT" property="cUserId"/> | |||||
<result column="c_user_nick_name" jdbcType="VARCHAR" property="cUserNickName" /> | |||||
<result column="c_user_phone" jdbcType="VARCHAR" property="cUserPhone" /> | |||||
<result column="earn_points" jdbcType="TINYINT" property="earnPoints"/> | |||||
<result column="increased_points" jdbcType="INTEGER" property="increasedPoints"/> | |||||
<result column="points_update_time" jdbcType="TIMESTAMP" property="pointsUpdateTime"/> | |||||
<result column="is_refund" jdbcType="TINYINT" property="isRefund"/> | |||||
<result column="order_status" jdbcType="TINYINT" property="orderStatus"/> | |||||
<result column="refund_id" jdbcType="VARCHAR" property="refundId" /> | |||||
<result column="refund_amount" jdbcType="INTEGER" property="refundAmount"/> | |||||
</resultMap> | |||||
<sql id="allColumns"> | |||||
`id`, `tenant_id`, `parent_tenant_id`, `source_app_id`, `source_type`,`notice_id`, `notice_create_time`, `notice_event_type`, | |||||
`summary`,`shop_name`, `shop_number`, `user_phone`, `user_number`, | |||||
`time_end`, `amount`, `pay_amount`, `transaction_id`, `create_time`, `update_time`, | |||||
`merchant_id`,`merchant_name`, `c_user_id`, `c_user_nick_name`, `c_user_phone`, | |||||
`earn_points`, `increased_points`, `points_update_time`, | |||||
`is_refund`, `order_status`, `refund_id`, `refund_amount` | |||||
</sql> | |||||
<sql id="dynamicWhereConditions"> | |||||
where 1 = 1 | |||||
<if test=" null != id "> | |||||
and `id` = #{id} | |||||
</if> | |||||
<if test=" null != tenantId and '' != tenantId"> | |||||
and `tenant_id` = #{tenantId} | |||||
</if> | |||||
<if test=" null != parentTenantId and '' != parentTenantId"> | |||||
and `parent_tenant_id` = #{parentTenantId} | |||||
</if> | |||||
<if test=" null != sourceAppId and '' != sourceAppId"> | |||||
and `source_app_id` = #{sourceAppId} | |||||
</if> | |||||
<if test=" null != sourceType and '' != sourceType"> | |||||
and `source_type` = #{sourceType} | |||||
</if> | |||||
<if test=" null != shopName "> | |||||
and `shop_name` like concat('%', #{shopName},'%') | |||||
</if> | |||||
<if test=" null != shopNumber and '' != shopNumber"> | |||||
and `shop_number` = #{shopNumber} | |||||
</if> | |||||
<if test=" null != userPhone and '' != userPhone"> | |||||
and `user_phone` = #{userPhone} | |||||
</if> | |||||
<if test=" null != userNumber and '' != userNumber"> | |||||
and `user_number` = #{userNumber} | |||||
</if> | |||||
<if test=" null != noticeId and '' != noticeId"> | |||||
and `notice_id` = #{noticeId} | |||||
</if> | |||||
<if test=" null != startTime "> | |||||
and `time_end` >= #{startTime} | |||||
</if> | |||||
<if test=" null != endTime"> | |||||
and `time_end` < #{endTime} | |||||
</if> | |||||
<if test=" null != transactionId and '' != transactionId"> | |||||
and `transaction_id` = #{transactionId} | |||||
</if> | |||||
<if test=" null != merchantId "> | |||||
and `merchant_id` = #{merchantId} | |||||
</if> | |||||
<if test=" null != merchantName and ''!=merchantName"> | |||||
and `merchant_name` like concat('%', #{merchantName},'%') | |||||
</if> | |||||
<if test=" null != cUserId "> | |||||
and `c_user_id` = #{cUserId} | |||||
</if> | |||||
<if test=" null != cUserNickName and ''!=cUserNickName"> | |||||
and `c_user_nick_name` like concat('%', #{cUserNickName},'%') | |||||
</if> | |||||
<if test=" null != cUserPhone and ''!=cUserPhone"> | |||||
and `c_user_phone` like concat('%', #{cUserPhone},'%') | |||||
</if> | |||||
<if test=" null != earnPoints "> | |||||
and `earn_points` = #{earnPoints} | |||||
</if> | |||||
<if test=" null != isRefund "> | |||||
and `is_refund` = #{isRefund} | |||||
</if> | |||||
<if test=" null != orderStatus "> | |||||
and `order_status` = #{orderStatus} | |||||
</if> | |||||
<if test=" null != refundId and '' != refundId"> | |||||
and `refund_id` = #{refundId} | |||||
</if> | |||||
<if test=" null != ids "> | |||||
and `id` in | |||||
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
#{idItem} | |||||
</foreach> | |||||
</if> | |||||
</sql> | |||||
<select id="findList" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from wx_third_party_orders | |||||
<include refid="dynamicWhereConditions"/> | |||||
<if test=" null != sortColumns">order by ${sortColumns}</if> | |||||
</select> | |||||
<select id="findListVo" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultType="com.iformall.domain.vo.WxThirdPartyOrdersVo"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from wx_third_party_orders | |||||
<include refid="dynamicWhereConditions"/> | |||||
</select> | |||||
<select id="getById" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from wx_third_party_orders | |||||
where `id` = #{id} | |||||
and tenant_id=#{tenantId} | |||||
</select> | |||||
<select id="getOrderByTransactionId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from wx_third_party_orders | |||||
where `is_refund` = 0 | |||||
and `source_type` = #{sourceType} | |||||
and `tenant_id` = #{tenantId} | |||||
and `transaction_id` = #{transactionId} | |||||
</select> | |||||
<select id="getRefundOrderByRefundId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from wx_third_party_orders | |||||
where `is_refund` = 1 | |||||
and `source_type` = #{sourceType} | |||||
and tenant_id = #{tenantId} | |||||
and `refund_id` = #{refundId} | |||||
</select> | |||||
<select id="getRefundOrderByTransactionId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap"> | |||||
select | |||||
<include refid="allColumns"/> | |||||
from wx_third_party_orders | |||||
where `is_refund` = 1 | |||||
and `source_type` = #{sourceType} | |||||
and `tenant_id` = #{tenantId} | |||||
and `transaction_id` = #{transactionId} | |||||
</select> | |||||
<insert id="insertNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" > | |||||
INSERT INTO wx_third_party_orders ( | |||||
`id`, `tenant_id`, `parent_tenant_id`,`source_app_id`, `source_type`, `notice_id`, `notice_create_time`, `notice_event_type`, | |||||
`summary`, `shop_name`, `shop_number`, `user_phone`, `user_number`,`time_end`, `amount`, `pay_amount`, `transaction_id`, `create_time`, `update_time`, | |||||
`merchant_id`,`merchant_name`, `c_user_id`, `c_user_nick_name`, `c_user_phone`, `earn_points`, `is_refund` | |||||
) | |||||
VALUES( | |||||
#{id},#{tenantId},#{parentTenantId},#{sourceAppId},#{sourceType},#{noticeId},#{noticeCreateTime},#{noticeEventType}, | |||||
#{summary},#{shopName},#{shopNumber},#{userPhone},#{userNumber},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{createTime},#{updateTime}, | |||||
#{merchantId},#{merchantName},#{cUserId},#{cUserNickName},#{cUserPhone},0,0 | |||||
); | |||||
</insert> | |||||
<update id="updatePoints" parameterType="com.iformall.domain.po.WxThirdPartyOrders"> | |||||
update wx_third_party_orders set | |||||
`earn_points` = 1, `increased_points` = #{increasedPoints}, `points_update_time` = #{pointsUpdateTime}, | |||||
`update_time` = #{updateTime} | |||||
where `id` = #{id} and `tenant_id` = #{tenantId} | |||||
</update> | |||||
<insert id="insertRefundNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" > | |||||
INSERT INTO wx_third_party_orders ( | |||||
`id`, `tenant_id`, `parent_tenant_id`,`source_app_id`, `source_type`, `notice_id`, `notice_create_time`, `notice_event_type`, | |||||
`summary`,`shop_name`, `shop_number`, `user_phone`, `user_number`, `time_end`, `amount`,`pay_amount`, `transaction_id`, `create_time`, `update_time`, | |||||
`merchant_id`,`merchant_name`, `c_user_id`, `c_user_nick_name`, `c_user_phone`, `earn_points`, `is_refund`, `refund_id`, `refund_amount` | |||||
) | |||||
VALUES( | |||||
#{id},#{tenantId},#{parentTenantId},#{sourceAppId},#{sourceType},#{noticeId},#{noticeCreateTime},#{noticeEventType}, | |||||
#{summary},#{shopName},#{shopNumber},#{userPhone},#{userNumber},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{createTime},#{updateTime}, | |||||
#{merchantId},#{merchantName},#{cUserId},#{cUserNickName},#{cUserPhone},0,1,#{refundId},#{refundAmount} | |||||
); | |||||
</insert> | |||||
<update id="updateOrderStatus" parameterType="com.iformall.domain.po.WxThirdPartyOrders"> | |||||
update wx_third_party_orders set | |||||
`order_status` = #{orderStatus}, | |||||
`update_time` = #{updateTime} | |||||
where `id` = #{id} and `tenant_id` = #{tenantId} | |||||
</update> | |||||
<select id="sumCirclePayment" parameterType="com.iformall.domain.po.BusinessCircleBase" resultType="Integer"> | |||||
select | |||||
IFNULL(SUM(`pay_amount`),0) as sum_pay_amount | |||||
from wx_third_party_orders | |||||
<include refid="dynamicWhereConditions"/> | |||||
and is_refund = 0 | |||||
</select> | |||||
<select id="sumCircleRefundAmount" parameterType="com.iformall.domain.po.BusinessCircleBase" resultType="Integer"> | |||||
select | |||||
IFNULL(SUM(`refund_amount`),0) as sum_refund_amount | |||||
from wx_third_party_orders | |||||
<include refid="dynamicWhereConditions"/> | |||||
and is_refund = 1 | |||||
</select> | |||||
</mapper> |