Merge branch 'dev' of http://gitea.dctpay.com/hurui/puhui-go into dev
commit
3f5df338dc
Binary file not shown.
@ -0,0 +1,455 @@ |
||||
package com.order.controller.business; |
||||
|
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.security.SessionObject; |
||||
import com.hfkj.common.security.UserCenter; |
||||
import com.hfkj.common.utils.DateUtil; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.config.CommonSysConst; |
||||
import com.hfkj.entity.BsOrderGoods; |
||||
import com.hfkj.entity.FileRecords; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.model.SecUserSessionObject; |
||||
|
||||
import com.hfkj.model.order.orderExport.MerOrderSettlementDetailModel; |
||||
import com.hfkj.model.order.orderExport.OrderGoodsExportModel; |
||||
import com.hfkj.model.order.orderExport.OrderSettlementModel; |
||||
import com.hfkj.model.order.orderExport.OrderSettlementSumModel; |
||||
import com.hfkj.service.file.FileRecordsService; |
||||
import com.hfkj.service.order.OrderSettlementService; |
||||
import com.hfkj.sysenum.SecUserObjectTypeEnum; |
||||
import com.hfkj.sysenum.fileRecords.FileRecordsEnum; |
||||
import com.hfkj.sysenum.order.OrderChildStatusEnum; |
||||
import com.hfkj.sysenum.order.OrderPayChannelEnum; |
||||
import com.hfkj.sysenum.order.OrderPayTypeEnum; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.beanutils.BeanUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.io.File; |
||||
import java.math.BigDecimal; |
||||
import java.util.*; |
||||
import java.util.concurrent.ArrayBlockingQueue; |
||||
import java.util.concurrent.ThreadPoolExecutor; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
@Controller |
||||
@RequestMapping(value="/settlement") |
||||
@Api(value="订单统计业务") |
||||
public class OrderSettlementController { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OrderSettlementController.class); |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
@Resource |
||||
private OrderSettlementService orderSettlementService; |
||||
@Resource |
||||
private FileRecordsService fileRecordsService; |
||||
|
||||
|
||||
@RequestMapping(value="/settlementDetail",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "结算详情") |
||||
public ResponseData settlementDetail(@RequestParam(value = "platform" , required = false) String platform, |
||||
@RequestParam(value = "merId" , required = false) Long merId, |
||||
@RequestParam(value = "payType" , required = false) Long payType, |
||||
@RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, |
||||
@RequestParam(value = "finishTimeE" , required = false) Long finishTimeE, HttpServletRequest request) { |
||||
try { |
||||
Map<String,Object> param = new HashMap<>(); |
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); |
||||
if (userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { |
||||
param.put("merId", merId); |
||||
} |
||||
if (SecUserObjectTypeEnum.type2.getCode() == userModel.getAccount().getObjectType()) { |
||||
param.put("merId", userModel.getAccount().getObjectId()); |
||||
} |
||||
param.put("platform", platform); |
||||
param.put("payType", payType); |
||||
param.put("finishTimeS", finishTimeS); |
||||
param.put("finishTimeE", finishTimeE); |
||||
|
||||
return ResponseMsgUtil.success(orderSettlementService.getDetail(param)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/exportSettlementDetail",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "导出结算详情") |
||||
public ResponseData exportSettlementDetail(@RequestParam(value = "platform" , required = false) String platform, |
||||
@RequestParam(value = "merId" , required = false) Long merId, |
||||
@RequestParam(value = "payType" , required = false) Long payType, |
||||
@RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, |
||||
@RequestParam(value = "finishTimeE" , required = false) Long finishTimeE, HttpServletRequest request) { |
||||
// 插入下载记录
|
||||
FileRecords fileRecords = new FileRecords(); |
||||
try { |
||||
|
||||
Map<String,Object> param = new HashMap<>(); |
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); |
||||
if (userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { |
||||
param.put("merId", merId); |
||||
} |
||||
if (SecUserObjectTypeEnum.type2.getCode() == userModel.getAccount().getObjectType()) { |
||||
param.put("merId", userModel.getAccount().getObjectId()); |
||||
} |
||||
param.put("platform", platform); |
||||
param.put("payType", payType); |
||||
param.put("finishTimeS", finishTimeS); |
||||
param.put("finishTimeE", finishTimeE); |
||||
|
||||
String dataSting = DateUtil.date2String(new Date(), DateUtil.YMDHMS); |
||||
|
||||
String fileUrl = CommonSysConst.getSysConfig().getFileUrl(); |
||||
String filePath = "/temporary/" + userModel.getAccount().getId() + "/" ; |
||||
String pathName = filePath + FileRecordsEnum.status10.getName() + "交易数据导出" + dataSting +".xlsx"; |
||||
|
||||
if (fileRecordsService.findExported(param.toString() , userModel.getAccount().getId())) { |
||||
throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "相同导出内容请勿重复点击!"); |
||||
} |
||||
|
||||
fileRecords.setCreateTime(new Date()); |
||||
fileRecords.setBusinessType(FileRecordsEnum.status10.getCode()); |
||||
fileRecords.setDownloadConditions(param.toString()); |
||||
fileRecords.setOpId(userModel.getAccount().getId()); |
||||
fileRecords.setOpName(userModel.getAccount().getUserName()); |
||||
fileRecords.setStatus(2); |
||||
fileRecords.setDownloadStatus(2); |
||||
fileRecords.setFileUrl(CommonSysConst.getSysConfig().getDomainName() + "/filesystem" + pathName); |
||||
fileRecords.setType("2"); |
||||
fileRecords.setTitle(FileRecordsEnum.status10.getName() + "交易数据导出" + dataSting + ".xls"); |
||||
fileRecordsService.create(fileRecords); |
||||
|
||||
// 创建线程
|
||||
ThreadPoolExecutor executor = new ThreadPoolExecutor( |
||||
2, // 核心线程数
|
||||
5, // 最大线程数
|
||||
1, // 线程空闲时间
|
||||
TimeUnit.MINUTES, // 时间单位
|
||||
new ArrayBlockingQueue<>(5), // 任务队列
|
||||
new ThreadPoolExecutor.CallerRunsPolicy() // 拒绝策略
|
||||
); |
||||
|
||||
// 提交任务给线程池
|
||||
executor.execute(() -> { |
||||
|
||||
try { |
||||
|
||||
List<MerOrderSettlementDetailModel> list = orderSettlementService.getDetail(param); |
||||
|
||||
File file = new File(fileUrl + filePath); |
||||
if (!file.exists()) { |
||||
file.mkdirs(); |
||||
} |
||||
|
||||
EasyExcel.write(fileUrl+pathName) |
||||
.head(MerOrderSettlementDetailModel.class) |
||||
.sheet(fileRecords.getTitle()) |
||||
.doWrite(list); |
||||
|
||||
fileRecords.setStatus(1); |
||||
fileRecords.setUpdateTime(new Date()); |
||||
fileRecordsService.update(fileRecords); |
||||
} catch (Exception e) { |
||||
fileRecords.setStatus(3); |
||||
fileRecords.setUpdateTime(new Date()); |
||||
fileRecords.setExt1(e.toString()); |
||||
fileRecordsService.update(fileRecords); |
||||
log.error("error!",e); |
||||
} |
||||
}); |
||||
|
||||
// 关闭线程池
|
||||
executor.shutdown(); |
||||
return ResponseMsgUtil.success(fileRecords); |
||||
|
||||
} catch (Exception e) { |
||||
fileRecords.setStatus(3); |
||||
fileRecords.setUpdateTime(new Date()); |
||||
fileRecordsService.update(fileRecords); |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/getSettlement",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "结算详情") |
||||
public ResponseData getSettlement(@RequestParam(value = "platform" , required = false) String platform, |
||||
@RequestParam(value = "merId" , required = false) Long merId, |
||||
@RequestParam(value = "payType" , required = false) Long payType, |
||||
@RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, |
||||
@RequestParam(value = "finishTimeE" , required = false) Long finishTimeE, HttpServletRequest request) { |
||||
try { |
||||
Map<String,Object> param = new HashMap<>(); |
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); |
||||
if (userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { |
||||
param.put("merId", merId); |
||||
} |
||||
if (SecUserObjectTypeEnum.type2.getCode() == userModel.getAccount().getObjectType()) { |
||||
param.put("merId", userModel.getAccount().getObjectId()); |
||||
} |
||||
param.put("platform", platform); |
||||
param.put("payType", payType); |
||||
param.put("finishTimeS", finishTimeS); |
||||
param.put("finishTimeE", finishTimeE); |
||||
|
||||
return ResponseMsgUtil.success(orderSettlementService.getSettlement(param)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/exportSettlement",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "导出结算") |
||||
public ResponseData exportSettlement(@RequestParam(value = "platform" , required = false) String platform, |
||||
@RequestParam(value = "merId" , required = false) Long merId, |
||||
@RequestParam(value = "payType" , required = false) Long payType, |
||||
@RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, |
||||
@RequestParam(value = "finishTimeE" , required = false) Long finishTimeE, HttpServletRequest request) { |
||||
// 插入下载记录
|
||||
FileRecords fileRecords = new FileRecords(); |
||||
try { |
||||
|
||||
Map<String,Object> param = new HashMap<>(); |
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); |
||||
if (userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { |
||||
param.put("merId", merId); |
||||
} |
||||
if (SecUserObjectTypeEnum.type2.getCode() == userModel.getAccount().getObjectType()) { |
||||
param.put("merId", userModel.getAccount().getObjectId()); |
||||
} |
||||
param.put("platform", platform); |
||||
param.put("payType", payType); |
||||
param.put("finishTimeS", finishTimeS); |
||||
param.put("finishTimeE", finishTimeE); |
||||
|
||||
String dataSting = DateUtil.date2String(new Date(), DateUtil.YMDHMS); |
||||
|
||||
String fileUrl = CommonSysConst.getSysConfig().getFileUrl(); |
||||
String filePath = "/temporary/" + userModel.getAccount().getId() + "/" ; |
||||
String pathName = filePath + FileRecordsEnum.status11.getName() + "交易数据导出" + dataSting +".xlsx"; |
||||
|
||||
if (fileRecordsService.findExported(param.toString() , userModel.getAccount().getId())) { |
||||
throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "相同导出内容请勿重复点击!"); |
||||
} |
||||
|
||||
fileRecords.setCreateTime(new Date()); |
||||
fileRecords.setBusinessType(FileRecordsEnum.status11.getCode()); |
||||
fileRecords.setDownloadConditions(param.toString()); |
||||
fileRecords.setOpId(userModel.getAccount().getId()); |
||||
fileRecords.setOpName(userModel.getAccount().getUserName()); |
||||
fileRecords.setStatus(2); |
||||
fileRecords.setDownloadStatus(2); |
||||
fileRecords.setFileUrl(CommonSysConst.getSysConfig().getDomainName() + "/filesystem" + pathName); |
||||
fileRecords.setType("2"); |
||||
fileRecords.setTitle(FileRecordsEnum.status11.getName() + "交易数据导出" + dataSting + ".xls"); |
||||
fileRecordsService.create(fileRecords); |
||||
|
||||
// 创建线程
|
||||
ThreadPoolExecutor executor = new ThreadPoolExecutor( |
||||
2, // 核心线程数
|
||||
5, // 最大线程数
|
||||
1, // 线程空闲时间
|
||||
TimeUnit.MINUTES, // 时间单位
|
||||
new ArrayBlockingQueue<>(5), // 任务队列
|
||||
new ThreadPoolExecutor.CallerRunsPolicy() // 拒绝策略
|
||||
); |
||||
|
||||
// 提交任务给线程池
|
||||
executor.execute(() -> { |
||||
|
||||
try { |
||||
|
||||
List<OrderSettlementModel> list = orderSettlementService.getSettlement(param); |
||||
|
||||
File file = new File(fileUrl + filePath); |
||||
if (!file.exists()) { |
||||
file.mkdirs(); |
||||
} |
||||
|
||||
EasyExcel.write(fileUrl+pathName) |
||||
.head(OrderSettlementModel.class) |
||||
.sheet(fileRecords.getTitle()) |
||||
.doWrite(list); |
||||
|
||||
fileRecords.setStatus(1); |
||||
fileRecords.setUpdateTime(new Date()); |
||||
fileRecordsService.update(fileRecords); |
||||
} catch (Exception e) { |
||||
fileRecords.setStatus(3); |
||||
fileRecords.setUpdateTime(new Date()); |
||||
fileRecords.setExt1(e.toString()); |
||||
fileRecordsService.update(fileRecords); |
||||
log.error("error!",e); |
||||
} |
||||
}); |
||||
|
||||
// 关闭线程池
|
||||
executor.shutdown(); |
||||
return ResponseMsgUtil.success(fileRecords); |
||||
|
||||
} catch (Exception e) { |
||||
fileRecords.setStatus(3); |
||||
fileRecords.setUpdateTime(new Date()); |
||||
fileRecordsService.update(fileRecords); |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/getSum",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "结算总和") |
||||
public ResponseData getSum(@RequestParam(value = "platform" , required = false) String platform, |
||||
@RequestParam(value = "merId" , required = false) Long merId, |
||||
@RequestParam(value = "payType" , required = false) Long payType, |
||||
@RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, |
||||
@RequestParam(value = "finishTimeE" , required = false) Long finishTimeE, HttpServletRequest request) { |
||||
try { |
||||
Map<String,Object> param = new HashMap<>(); |
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); |
||||
if (userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { |
||||
param.put("merId", merId); |
||||
} |
||||
if (SecUserObjectTypeEnum.type2.getCode() == userModel.getAccount().getObjectType()) { |
||||
param.put("merId", userModel.getAccount().getObjectId()); |
||||
} |
||||
param.put("platform", platform); |
||||
param.put("payType", payType); |
||||
param.put("finishTimeS", finishTimeS); |
||||
param.put("finishTimeE", finishTimeE); |
||||
|
||||
return ResponseMsgUtil.success(orderSettlementService.getSum(param)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/exportSettlementSum",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "导出结算总和") |
||||
public ResponseData exportSettlementSum(@RequestParam(value = "platform" , required = false) String platform, |
||||
@RequestParam(value = "merId" , required = false) Long merId, |
||||
@RequestParam(value = "payType" , required = false) Long payType, |
||||
@RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, |
||||
@RequestParam(value = "finishTimeE" , required = false) Long finishTimeE, HttpServletRequest request) { |
||||
// 插入下载记录
|
||||
FileRecords fileRecords = new FileRecords(); |
||||
try { |
||||
|
||||
Map<String,Object> param = new HashMap<>(); |
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); |
||||
if (userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { |
||||
param.put("merId", merId); |
||||
} |
||||
if (SecUserObjectTypeEnum.type2.getCode() == userModel.getAccount().getObjectType()) { |
||||
param.put("merId", userModel.getAccount().getObjectId()); |
||||
} |
||||
param.put("platform", platform); |
||||
param.put("payType", payType); |
||||
param.put("finishTimeS", finishTimeS); |
||||
param.put("finishTimeE", finishTimeE); |
||||
|
||||
String dataSting = DateUtil.date2String(new Date(), DateUtil.YMDHMS); |
||||
|
||||
String fileUrl = CommonSysConst.getSysConfig().getFileUrl(); |
||||
String filePath = "/temporary/" + userModel.getAccount().getId() + "/" ; |
||||
String pathName = filePath + FileRecordsEnum.status12.getName() + "交易数据导出" + dataSting +".xlsx"; |
||||
|
||||
if (fileRecordsService.findExported(param.toString() , userModel.getAccount().getId())) { |
||||
throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "相同导出内容请勿重复点击!"); |
||||
} |
||||
|
||||
fileRecords.setCreateTime(new Date()); |
||||
fileRecords.setBusinessType(FileRecordsEnum.status12.getCode()); |
||||
fileRecords.setDownloadConditions(param.toString()); |
||||
fileRecords.setOpId(userModel.getAccount().getId()); |
||||
fileRecords.setOpName(userModel.getAccount().getUserName()); |
||||
fileRecords.setStatus(2); |
||||
fileRecords.setDownloadStatus(2); |
||||
fileRecords.setFileUrl(CommonSysConst.getSysConfig().getDomainName() + "/filesystem" + pathName); |
||||
fileRecords.setType("2"); |
||||
fileRecords.setTitle(FileRecordsEnum.status12.getName() + "交易数据导出" + dataSting + ".xls"); |
||||
fileRecordsService.create(fileRecords); |
||||
|
||||
// 创建线程
|
||||
ThreadPoolExecutor executor = new ThreadPoolExecutor( |
||||
2, // 核心线程数
|
||||
5, // 最大线程数
|
||||
1, // 线程空闲时间
|
||||
TimeUnit.MINUTES, // 时间单位
|
||||
new ArrayBlockingQueue<>(5), // 任务队列
|
||||
new ThreadPoolExecutor.CallerRunsPolicy() // 拒绝策略
|
||||
); |
||||
|
||||
// 提交任务给线程池
|
||||
executor.execute(() -> { |
||||
|
||||
try { |
||||
|
||||
List<OrderSettlementSumModel> list = orderSettlementService.getSum(param); |
||||
|
||||
File file = new File(fileUrl + filePath); |
||||
if (!file.exists()) { |
||||
file.mkdirs(); |
||||
} |
||||
|
||||
EasyExcel.write(fileUrl+pathName) |
||||
.head(OrderSettlementSumModel.class) |
||||
.sheet(fileRecords.getTitle()) |
||||
.doWrite(list); |
||||
|
||||
fileRecords.setStatus(1); |
||||
fileRecords.setUpdateTime(new Date()); |
||||
fileRecordsService.update(fileRecords); |
||||
} catch (Exception e) { |
||||
fileRecords.setStatus(3); |
||||
fileRecords.setUpdateTime(new Date()); |
||||
fileRecords.setExt1(e.toString()); |
||||
fileRecordsService.update(fileRecords); |
||||
log.error("error!",e); |
||||
} |
||||
}); |
||||
|
||||
// 关闭线程池
|
||||
executor.shutdown(); |
||||
return ResponseMsgUtil.success(fileRecords); |
||||
|
||||
} catch (Exception e) { |
||||
fileRecords.setStatus(3); |
||||
fileRecords.setUpdateTime(new Date()); |
||||
fileRecordsService.update(fileRecords); |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,69 @@ |
||||
package com.order.controller.notify; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.common.utils.HttpsUtils; |
||||
import com.hfkj.config.CommonSysConst; |
||||
import com.hfkj.jd.JdService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.PrintWriter; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/jdNotify") |
||||
@Api(value = "京东回调") |
||||
public class JdNotify { |
||||
private static final Logger log = LoggerFactory.getLogger(JdService.class); |
||||
|
||||
@RequestMapping(value = "/notify", method = RequestMethod.POST) |
||||
@ApiOperation(value = "回调") |
||||
@ResponseBody |
||||
public void notify(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) { |
||||
try { |
||||
|
||||
JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class); |
||||
|
||||
log.info("============回调任务Start============="); |
||||
log.info("尖椒订单充值-回调参数: " + dataObject); |
||||
log.info("============回调任务End============="); |
||||
|
||||
|
||||
response.setCharacterEncoding("UTF-8"); |
||||
response.setContentType("text/html;charset=utf-8"); |
||||
PrintWriter writer= response.getWriter(); |
||||
writer.write("SUCCESS"); |
||||
|
||||
|
||||
} catch (Exception e) { |
||||
log.error("WechatPayController --> wechatNotify() error!", e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/callbackToken", method = RequestMethod.GET) |
||||
@ApiOperation(value = "token回调") |
||||
@ResponseBody |
||||
public void notify(@RequestParam("code") String code) { |
||||
try { |
||||
|
||||
log.info("============token回调任务Start============="); |
||||
log.info("token回调-回调参数: " + code); |
||||
JSONObject object = new JSONObject(); |
||||
object.put("app_key", CommonSysConst.getSysConfig().getJDAppKey()); |
||||
object.put("app_secret", CommonSysConst.getSysConfig().getJDAppSecret()); |
||||
object.put("code", code); |
||||
object.put("grant_type", "authorization_code"); |
||||
JSONObject jsonObject = HttpsUtils.doGet("https://open-oauth.jd.com/oauth2/authorizeForVOP", object); |
||||
log.info("token回调-回调参数: " + jsonObject); |
||||
log.info("============token回调任务End============="); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("WechatPayController --> wechatNotify() error!", e); |
||||
} |
||||
} |
||||
} |
Binary file not shown.
@ -0,0 +1,113 @@ |
||||
package com.hfkj.common.utils; |
||||
|
||||
import javafx.util.Pair; |
||||
import org.apache.commons.codec.binary.Base64; |
||||
|
||||
import javax.crypto.Cipher; |
||||
import java.nio.charset.StandardCharsets; |
||||
import java.security.*; |
||||
import java.security.interfaces.RSAPrivateKey; |
||||
import java.security.interfaces.RSAPublicKey; |
||||
import java.security.spec.PKCS8EncodedKeySpec; |
||||
import java.security.spec.X509EncodedKeySpec; |
||||
|
||||
public final class RsaCoderUtils { |
||||
|
||||
/** |
||||
* 生成公私钥 |
||||
* |
||||
* @return |
||||
* @throws NoSuchAlgorithmException |
||||
*/ |
||||
public static Pair<String, String> genKeyPair() throws NoSuchAlgorithmException { |
||||
// KeyPairGenerator类用于生成公钥和私钥对,基于RSA算法生成对象
|
||||
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA"); |
||||
// 初始化密钥对生成器,密钥大小为96-1024位
|
||||
keyPairGen.initialize(1024, new SecureRandom()); |
||||
// 生成一个密钥对,保存在keyPair中
|
||||
KeyPair keyPair = keyPairGen.generateKeyPair(); |
||||
// 得到私钥
|
||||
RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); |
||||
// 得到公钥
|
||||
RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); |
||||
String publicKeyString = new String(Base64.encodeBase64(publicKey.getEncoded())); |
||||
// 得到私钥字符串
|
||||
String privateKeyString = new String(Base64.encodeBase64((privateKey.getEncoded()))); |
||||
return new Pair<>(publicKeyString, privateKeyString); |
||||
} |
||||
|
||||
/** |
||||
* RSA私钥加密 |
||||
* |
||||
* @param str 加密字符串 |
||||
* @param privateKey 私钥 |
||||
* @return 密文 |
||||
* @throws Exception 加密过程中的异常信息 |
||||
*/ |
||||
public static String encryptByPrivateKey(String str, String privateKey) throws Exception { |
||||
//base64编码的公钥
|
||||
byte[] decoded = Base64.decodeBase64(privateKey); |
||||
RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded)); |
||||
//RSA解密
|
||||
Cipher cipher = Cipher.getInstance("RSA"); |
||||
cipher.init(Cipher.ENCRYPT_MODE, priKey); |
||||
return Base64.encodeBase64String(cipher.doFinal(str.getBytes(StandardCharsets.UTF_8))); |
||||
} |
||||
|
||||
/** |
||||
* RSA公钥加密 |
||||
* |
||||
* @param str 加密字符串 |
||||
* @return 密文 |
||||
* @throws Exception 加密过程中的异常信息 |
||||
*/ |
||||
public static String encryptByPublicKey(String str, String publicKey) throws Exception { |
||||
//base64编码的公钥
|
||||
byte[] decoded = Base64.decodeBase64(publicKey); |
||||
RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded)); |
||||
//RSA加密
|
||||
Cipher cipher = Cipher.getInstance("RSA"); |
||||
cipher.init(Cipher.ENCRYPT_MODE, pubKey); |
||||
return Base64.encodeBase64String(cipher.doFinal(str.getBytes(StandardCharsets.UTF_8))); |
||||
} |
||||
|
||||
/** |
||||
* RSA公钥解密 |
||||
* |
||||
* @param str 加密字符串 |
||||
* @param publicKey 公钥 |
||||
* @return 铭文 |
||||
* @throws Exception 解密过程中的异常信息 |
||||
*/ |
||||
public static String decryptByPublicKey(String str, String publicKey) throws Exception { |
||||
//64位解码加密后的字符串
|
||||
byte[] inputByte = Base64.decodeBase64(str.getBytes(StandardCharsets.UTF_8)); |
||||
//base64编码的私钥
|
||||
byte[] decoded = Base64.decodeBase64(publicKey); |
||||
RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded)); |
||||
//RSA加密
|
||||
Cipher cipher = Cipher.getInstance("RSA"); |
||||
cipher.init(Cipher.DECRYPT_MODE, pubKey); |
||||
return new String(cipher.doFinal(inputByte)); |
||||
} |
||||
|
||||
/** |
||||
* RSA私钥解密 |
||||
* |
||||
* @param str 加密字符串 |
||||
* @return 铭文 |
||||
* @throws Exception 解密过程中的异常信息 |
||||
*/ |
||||
public static String decryptByPrivateKey(String str, String privateKey) throws Exception { |
||||
//64位解码加密后的字符串
|
||||
byte[] inputByte = Base64.decodeBase64(str.getBytes(StandardCharsets.UTF_8)); |
||||
//base64编码的私钥
|
||||
byte[] decoded = Base64.decodeBase64(privateKey); |
||||
RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded)); |
||||
//RSA解密
|
||||
Cipher cipher = Cipher.getInstance("RSA"); |
||||
cipher.init(Cipher.DECRYPT_MODE, priKey); |
||||
return new String(cipher.doFinal(inputByte)); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,63 @@ |
||||
package com.hfkj.jd; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.common.utils.HttpsUtils; |
||||
import com.hfkj.common.utils.RsaCoderUtils; |
||||
import com.hfkj.config.CommonSysConst; |
||||
import com.hfkj.meituan.MeiTuanService; |
||||
import com.jd.open.api.sdk.DefaultJdClient; |
||||
import com.jd.open.api.sdk.JdClient; |
||||
import org.apache.commons.codec.digest.DigestUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import java.net.URLEncoder; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @ClassName JdService |
||||
* @Author Sum1Dream |
||||
* @Description 京东服务 |
||||
* @Date 2024/10/11 下午3:25 |
||||
**/ |
||||
public class JdService { |
||||
private static Logger log = LoggerFactory.getLogger(JdService.class); |
||||
|
||||
/** |
||||
* UTF_8 |
||||
*/ |
||||
public static final String UTF_8 = "utf-8"; |
||||
/** |
||||
* 用户名 |
||||
*/ |
||||
private static final String USERNAME = "惠兑重庆VOP", |
||||
/** |
||||
* 明文密码,后续需要通过RSA加密 |
||||
*/ |
||||
PLAINTEXT_PASSWORD = "hdcs1234", |
||||
/** |
||||
* 回调地址,注册应用时配置的授权回调地址 |
||||
*/ |
||||
REDIRECT_URI = CommonSysConst.getSysConfig().getDomainName() + "/order/jdNotify/callbackToken", |
||||
/** |
||||
* RSA私钥 |
||||
*/ |
||||
PRIVATE_RSA_KEY = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMEtt0kF02YBxPXzXyqzCtr1zkuj8NXLiqqSCDAfU6zWB1T1GUEpCfNukPBeZ9nXGj+jbTom8RFllNXbnOkW01Zn2VoyePh8TRWQbToXi+i/JQ162GzpF0GdPsUhJSrB5Z2QzK4UVXXkpPHhQHR8NKQhvTRkoRLfOy+oXWL8PS2hAgMBAAECgYBySo/j/jRiZ62WLlUhuCg1/7P8AJSeiPwTiq6Zeg9RdJeF5jT43kTq54GNFO2wbpkzCYe4Hg4GUulJ1dLx/PUvYquRpM4jGznxDxBA10mNyjx0O+SHcY+ZlOYWIKhEq4MeeJhtHhoFrlgcMNIyofhRDbFzrRak48GrcZDQC4/cIQJBAPwxtEwMnetPveLExR1UsygdVKwoWoGNL5Hkhcx6b2N2Qapk5aHB5haUEXeg1ShrL4C/kE1lsMAIdpVS9lWd4x0CQQDEGASnnB2oPHjvNfj88klpYTvPJRi3ORQPtlfz36kv+29QFxB9Mt1u39ttopw5G2x7QvTtL542w878brrmS8lVAkEA4k7QFjZ0N8cVBLvCjrGFG4hGhT6pCPxjJa5GCtoLvttNzdRA5EkVaklw60LeRSj6NbSxj2Kjm498qj8KYoYOWQJATJhRISMy1mcgmdeMNUlycW4gjY4g9FigRG7mNgU0MeDVnwQTVcQLiGZ6cH2m5guXOSJzRz5lX2DmteWOrawGrQJBAMKLfeTnYkVpXw9MABcR/9L9myG3FKwOHBIqD0wK+QVahi9byFk8GFXD4OlBQ1ZSxHqsUuxWqLVSa3sWBCKpLo8="; |
||||
|
||||
public static JSONObject getAccessToken() throws Exception { |
||||
String encodeRedirectUri = URLEncoder.encode(REDIRECT_URI, UTF_8); |
||||
String encodeUsername = URLEncoder.encode(USERNAME, UTF_8); |
||||
String md5Password = DigestUtils.md5Hex(PLAINTEXT_PASSWORD); |
||||
String ciphertextPassword = RsaCoderUtils.encryptByPrivateKey(md5Password, PRIVATE_RSA_KEY); |
||||
String encodePassword = URLEncoder.encode(ciphertextPassword, UTF_8); |
||||
|
||||
JSONObject object = new JSONObject(); |
||||
object.put("app_key", CommonSysConst.getSysConfig().getJDAppKey()); |
||||
object.put("redirect_uri", encodeRedirectUri); |
||||
object.put("username", encodeUsername); |
||||
object.put("password", encodePassword); |
||||
object.put("response_type", "code"); |
||||
object.put("scope", "snsapi_base"); |
||||
return HttpsUtils.doGet("https://open-oauth.jd.com/oauth2/authorizeForVOP", object); |
||||
} |
||||
} |
@ -0,0 +1,58 @@ |
||||
package com.hfkj.model.order.orderExport; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||
import lombok.Data; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @ClassName MerOrderSettlementDetailModel |
||||
* @Author Sum1Dream |
||||
* @Description 商户订单结算详情 |
||||
* @Date 2024/9/29 上午10:50 |
||||
**/ |
||||
@Data |
||||
public class MerOrderSettlementDetailModel { |
||||
|
||||
@ColumnWidth(50) |
||||
@ExcelProperty("商品名称") |
||||
public String goodsName; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("商户名称") |
||||
public String merName; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("业务类型") |
||||
public String businessType; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("登录平台") |
||||
public String platform; |
||||
|
||||
@ColumnWidth(40) |
||||
@ExcelProperty("订单号") |
||||
public String orderNo; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty("子订单号") |
||||
public String childOrderNo; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("业务信息") |
||||
public String business; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"支付金额"}) |
||||
public BigDecimal payRealPrice; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"支付方式"}) |
||||
public String payType; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("收货时间") |
||||
public String finishTime; |
||||
} |
@ -0,0 +1,120 @@ |
||||
package com.hfkj.model.order.orderExport; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||
import lombok.Data; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @ClassName OrderGoodsExportModel |
||||
* @Author Sum1Dream |
||||
* @Description 实物订单导出 |
||||
* @Date 2024/8/12 下午5:07 |
||||
**/ |
||||
@Data |
||||
public class OrderMeiTuanExportModel { |
||||
|
||||
@ColumnWidth(50) |
||||
@ExcelProperty("商品名称") |
||||
public String goodsName; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("商户名称") |
||||
public String merName; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("类型名称") |
||||
public String goodsTypeName; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("品牌名称") |
||||
public String goodsBrandName; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("用户手机号") |
||||
public String userPhone; |
||||
|
||||
@ColumnWidth(40) |
||||
@ExcelProperty("订单号") |
||||
public String orderNo; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty("子订单号") |
||||
public String childOrderNo; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("物流单号") |
||||
public String logisticsNo; |
||||
|
||||
@ColumnWidth(30) |
||||
@ExcelProperty("商品规格") |
||||
public String goodsSpecsName; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("商品价格") |
||||
public BigDecimal goodsPrice; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("购买数量") |
||||
public Integer goodsCount; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"交易信息", "订单金额"}) |
||||
public BigDecimal totalPrice; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"交易信息", "总优惠"}) |
||||
public BigDecimal totalDeductionPrice; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"交易信息", "优惠券优惠"}) |
||||
public BigDecimal couponDiscountPrice; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"交易信息", "积分抵扣"}) |
||||
public BigDecimal integralDiscountPrice; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"交易信息", "实付金额"}) |
||||
public BigDecimal payRealPrice; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"交易信息", "支付渠道"}) |
||||
public String payChannel; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"交易信息", "支付方式"}) |
||||
public String payType; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"交易信息", "支付单号"}) |
||||
public String paySerialNo; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"交易信息", "交易状态"}) |
||||
public String tradeStatus; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"交易信息", "创建时间"}) |
||||
public Date createTime; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"交易信息", "支付时间"}) |
||||
public Date payTime; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("物流状态") |
||||
public String logisticsStatusDesc; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("更新时间") |
||||
public Date updateTime; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("确认收货时间") |
||||
public Date finishTime; |
||||
|
||||
|
||||
} |
@ -0,0 +1,39 @@ |
||||
package com.hfkj.model.order.orderExport; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||
import lombok.Data; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @ClassName MerOrderSettlementDetailModel |
||||
* @Author Sum1Dream |
||||
* @Description 商户订单结算详情 |
||||
* @Date 2024/9/29 上午10:50 |
||||
**/ |
||||
@Data |
||||
public class OrderSettlementModel { |
||||
|
||||
|
||||
@ColumnWidth(40) |
||||
@ExcelProperty("商户名称") |
||||
public String merName; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("支付方式") |
||||
public String payType; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("业务类型") |
||||
public String businessType; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"结算金额"}) |
||||
public BigDecimal payRealPrice; |
||||
|
||||
@ColumnWidth(30) |
||||
@ExcelProperty("结算日期") |
||||
public String time; |
||||
} |
@ -0,0 +1,34 @@ |
||||
package com.hfkj.model.order.orderExport; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||
import lombok.Data; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @ClassName MerOrderSettlementDetailModel |
||||
* @Author Sum1Dream |
||||
* @Description 商户订单结算详情 |
||||
* @Date 2024/9/29 上午10:50 |
||||
**/ |
||||
@Data |
||||
public class OrderSettlementSumModel { |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("业务类型") |
||||
public String businessType; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty("支付方式") |
||||
public String payType; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty({"结算金额"}) |
||||
public BigDecimal payRealPrice; |
||||
|
||||
@ColumnWidth(30) |
||||
@ExcelProperty("结算日期") |
||||
public String time; |
||||
} |
@ -0,0 +1,47 @@ |
||||
package com.hfkj.service.order; |
||||
|
||||
import com.hfkj.model.order.orderExport.MerOrderSettlementDetailModel; |
||||
import com.hfkj.model.order.orderExport.OrderSettlementModel; |
||||
import com.hfkj.model.order.orderExport.OrderSettlementSumModel; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @ClassName OrderSettlementService |
||||
* @Author Sum1Dream |
||||
* @Description 订单结算 |
||||
* @Date 2024/9/29 下午4:12 |
||||
**/ |
||||
public interface OrderSettlementService { |
||||
|
||||
/** |
||||
* @MethodName getDetail |
||||
* @Description: 获取结算订单详情 |
||||
* @param map |
||||
* @return: java.util.List<com.hfkj.model.order.orderExport.MerOrderSettlementDetailModel> |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/9/29 下午4:14 |
||||
*/ |
||||
List<MerOrderSettlementDetailModel> getDetail(Map<String,Object> map); |
||||
|
||||
/** |
||||
* @MethodName getSettlement |
||||
* @Description: 结算订单 |
||||
* @param map |
||||
* @return: java.util.List<com.hfkj.model.order.orderExport.OrderSettlementModel> |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/9/29 下午4:14 |
||||
*/ |
||||
List<OrderSettlementModel> getSettlement(Map<String,Object> map); |
||||
|
||||
/** |
||||
* @MethodName getSum |
||||
* @Description: 结算总和 |
||||
* @param map |
||||
* @return: java.util.List<com.hfkj.model.order.orderExport.OrderSettlementSumModel> |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/9/29 下午4:14 |
||||
*/ |
||||
List<OrderSettlementSumModel> getSum(Map<String,Object> map); |
||||
} |
@ -0,0 +1,370 @@ |
||||
package com.hfkj.service.order.impl; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.common.utils.DateUtil; |
||||
import com.hfkj.entity.*; |
||||
import com.hfkj.model.order.OrderCouponModel; |
||||
import com.hfkj.model.order.orderExport.MerOrderSettlementDetailModel; |
||||
import com.hfkj.model.order.orderExport.OrderSettlementModel; |
||||
import com.hfkj.model.order.orderExport.OrderSettlementSumModel; |
||||
import com.hfkj.service.BsMerService; |
||||
import com.hfkj.service.coupon.BsOrderCouponService; |
||||
import com.hfkj.service.goods.*; |
||||
import com.hfkj.service.order.OrderSettlementService; |
||||
import com.hfkj.sysenum.UserLoginPlatform; |
||||
import com.hfkj.sysenum.order.OrderPayTypeEnum; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.math.BigDecimal; |
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
@Service("orderSettlementService") |
||||
public class OrderSettlementServiceImpl implements OrderSettlementService { |
||||
|
||||
@Resource |
||||
private BsOrderCouponService orderCouponService; |
||||
@Resource |
||||
private BsOrderGoodsService goodsService; |
||||
@Resource |
||||
private BsOrderCinemaService cinemaService; |
||||
@Resource |
||||
private BsOrderStarbucksService starbucksService; |
||||
@Resource |
||||
private BsOrderMeiTuanService meiTuanService; |
||||
@Resource |
||||
private BsOrderMemberService memberService; |
||||
@Resource |
||||
private BsMerService bsMerService; |
||||
@Override |
||||
public List<MerOrderSettlementDetailModel> getDetail(Map<String, Object> map) { |
||||
return settlementData(map); |
||||
} |
||||
|
||||
@Override |
||||
public List<OrderSettlementModel> getSettlement(Map<String, Object> map) { |
||||
|
||||
List<MerOrderSettlementDetailModel> list = settlementData(map); |
||||
|
||||
Map<String, List<MerOrderSettlementDetailModel>> merList = list.stream().collect(Collectors.groupingBy(MerOrderSettlementDetailModel:: getMerName)); |
||||
|
||||
List<OrderSettlementModel> settlementModels = new ArrayList<>(); |
||||
OrderSettlementModel settlementModel; |
||||
|
||||
for (String key : merList.keySet()) { |
||||
Map<String, List<MerOrderSettlementDetailModel>> detailList = merList.get(key).stream().collect(Collectors.groupingBy(MerOrderSettlementDetailModel:: getBusinessType)); |
||||
for (String key1 : detailList.keySet()) { |
||||
Map<String, List<MerOrderSettlementDetailModel>> listMap = detailList.get(key1).stream().collect(Collectors.groupingBy(MerOrderSettlementDetailModel:: getPayType)); |
||||
for (String key2 : listMap.keySet()) { |
||||
settlementModel = new OrderSettlementModel(); |
||||
if (map.get("finishTimeS") == null) { |
||||
settlementModel.setTime("全时间段"); |
||||
} else { |
||||
settlementModel.setTime(DateUtil.date2String(DateUtil.long2Date(MapUtils.getLong(map , "finishTimeS")) , DateUtil.Y_M_D) + "-" + DateUtil.date2String(DateUtil.long2Date(MapUtils.getLong(map , "finishTimeE")) , DateUtil.Y_M_D)); |
||||
} |
||||
settlementModel.setPayType(key2); |
||||
settlementModel.setBusinessType(key1); |
||||
settlementModel.setMerName(key); |
||||
BigDecimal reduce = listMap.get(key2).stream().map(MerOrderSettlementDetailModel::getPayRealPrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
||||
settlementModel.setPayRealPrice(reduce); |
||||
settlementModels.add(settlementModel); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
} |
||||
return settlementModels; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public List<OrderSettlementSumModel> getSum(Map<String, Object> map) { |
||||
|
||||
List<MerOrderSettlementDetailModel> list = settlementData(map); |
||||
|
||||
List<OrderSettlementSumModel> sumModels = new ArrayList<>(); |
||||
OrderSettlementSumModel sumModel; |
||||
|
||||
Map<String, List<MerOrderSettlementDetailModel>> detailList = list.stream().collect(Collectors.groupingBy(MerOrderSettlementDetailModel:: getBusinessType)); |
||||
for (String key1 : detailList.keySet()) { |
||||
Map<String, List<MerOrderSettlementDetailModel>> listMap = detailList.get(key1).stream().collect(Collectors.groupingBy(MerOrderSettlementDetailModel:: getPayType)); |
||||
for (String key2 : listMap.keySet()) { |
||||
sumModel = new OrderSettlementSumModel(); |
||||
if (map.get("finishTimeS") == null) { |
||||
sumModel.setTime("全时间段"); |
||||
} else { |
||||
sumModel.setTime(DateUtil.date2String(DateUtil.long2Date(MapUtils.getLong(map , "finishTimeS")) , DateUtil.Y_M_D) + "-" + DateUtil.date2String(DateUtil.long2Date(MapUtils.getLong(map , "finishTimeE")) , DateUtil.Y_M_D)); |
||||
} |
||||
sumModel.setPayType(key2); |
||||
sumModel.setBusinessType(key1); |
||||
BigDecimal reduce = listMap.get(key2).stream().map(MerOrderSettlementDetailModel::getPayRealPrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
||||
sumModel.setPayRealPrice(reduce); |
||||
sumModels.add(sumModel); |
||||
} |
||||
|
||||
|
||||
} |
||||
return sumModels; |
||||
} |
||||
|
||||
// 查询结算订单详情
|
||||
private List<MerOrderSettlementDetailModel> settlementData(Map<String, Object> map) { |
||||
List<MerOrderSettlementDetailModel> list = new ArrayList<>(); |
||||
// 卡券订单整合
|
||||
list = couponOrder(map , list); |
||||
// 查询实物订单
|
||||
list = goodsOrder(map , list); |
||||
// 查询电影票订单
|
||||
list = cinemaOrder(map , list); |
||||
// 查询星巴克
|
||||
list = starbucksOrder(map , list); |
||||
// 查询美团订单
|
||||
list = meiTuanOrder(map , list); |
||||
// 查询会员订单
|
||||
list = membersOrder(map , list); |
||||
|
||||
return list; |
||||
} |
||||
|
||||
// 实物订单整合
|
||||
private List<MerOrderSettlementDetailModel> goodsOrder(Map<String, Object> map, List<MerOrderSettlementDetailModel> list) { |
||||
// 查询实物订单
|
||||
List<BsOrderGoods> orderGoodsList = goodsService.getListFinish(map); |
||||
MerOrderSettlementDetailModel model; |
||||
for (BsOrderGoods orderGoods : orderGoodsList) { |
||||
model = new MerOrderSettlementDetailModel(); |
||||
model.setBusinessType("实物订单"); |
||||
model.setGoodsName(orderGoods.getGoodsName()); |
||||
model.setMerName(findMerName(orderGoods.getMerId())); |
||||
if (orderGoods.getPlatformCode() != null) { |
||||
model.setPlatform(UserLoginPlatform.getDataByType(orderGoods.getPlatformCode()).getName()); |
||||
} |
||||
model.setOrderNo(orderGoods.getOrderNo()); |
||||
model.setChildOrderNo(orderGoods.getChildOrderNo()); |
||||
model.setBusiness(orderGoods.getLogisticsNo()); |
||||
if (orderGoods.getPayRealPrice() == null) { |
||||
model.setPayRealPrice(new BigDecimal(0)); |
||||
} else { |
||||
model.setPayRealPrice(orderGoods.getPayRealPrice()); |
||||
} |
||||
|
||||
if (orderGoods.getPayType() != null) { |
||||
model.setPayType(OrderPayTypeEnum.getData(orderGoods.getPayType()).getName()); |
||||
} else { |
||||
model.setPayType("未知"); |
||||
} |
||||
if (orderGoods.getFinishTime() != null) { |
||||
model.setFinishTime(DateUtil.date2String(orderGoods.getFinishTime() , DateUtil.Y_M_D_HMS)); |
||||
} else { |
||||
model.setFinishTime(DateUtil.date2String(orderGoods.getUpdateTime() , DateUtil.Y_M_D_HMS)); |
||||
} |
||||
|
||||
list.add(model); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
// 卡券订单整合
|
||||
private List<MerOrderSettlementDetailModel> couponOrder(Map<String, Object> map , List<MerOrderSettlementDetailModel> list) { |
||||
// 查询卡券订单
|
||||
List<BsOrderCoupon> orderCouponList = orderCouponService.getOrderCouponList(map); |
||||
Map<String , Object> mapCou = new HashMap<>(); |
||||
mapCou.put("couStatus", 2); |
||||
// 查询卡券订单卡密
|
||||
List<OrderCouponModel> orderCouponModelList = orderCouponService.getOrderList(mapCou); |
||||
|
||||
MerOrderSettlementDetailModel model; |
||||
for (BsOrderCoupon orderCoupon : orderCouponList) { |
||||
String business = couponCode(orderCoupon.getChildOrderNo() , orderCouponModelList); |
||||
if (business != null) { |
||||
model = new MerOrderSettlementDetailModel(); |
||||
model.setGoodsName(orderCoupon.getGoodsName()); |
||||
model.setBusinessType("卡券订单"); |
||||
model.setMerName(findMerName(orderCoupon.getMerId())); |
||||
if (orderCoupon.getPlatformCode() != null) { |
||||
model.setPlatform(UserLoginPlatform.getDataByType(orderCoupon.getPlatformCode()).getName()); |
||||
} |
||||
model.setOrderNo(orderCoupon.getOrderNo()); |
||||
model.setChildOrderNo(orderCoupon.getChildOrderNo()); |
||||
model.setBusiness(business); |
||||
if (orderCoupon.getPayRealPrice() == null) { |
||||
model.setPayRealPrice(new BigDecimal(0)); |
||||
} else { |
||||
model.setPayRealPrice(orderCoupon.getPayRealPrice()); |
||||
} |
||||
if (orderCoupon.getPayType() != null) { |
||||
model.setPayType(OrderPayTypeEnum.getData(orderCoupon.getPayType()).getName()); |
||||
} else { |
||||
model.setPayType("未知"); |
||||
} |
||||
model.setFinishTime(DateUtil.date2String(orderCoupon.getUpdateTime() , DateUtil.Y_M_D_HMS)); |
||||
list.add(model); |
||||
} |
||||
|
||||
} |
||||
|
||||
return list; |
||||
} |
||||
// 整合电影票订单
|
||||
private List<MerOrderSettlementDetailModel> cinemaOrder(Map<String, Object> map, List<MerOrderSettlementDetailModel> list) { |
||||
// 查询电影票订单
|
||||
List<BsOrderCinema> orderCinemaList = cinemaService.getListFinish(map); |
||||
MerOrderSettlementDetailModel model; |
||||
for (BsOrderCinema orderCinema : orderCinemaList) { |
||||
model = new MerOrderSettlementDetailModel(); |
||||
model.setBusinessType("电影票订单"); |
||||
model.setGoodsName(orderCinema.getGoodsName()); |
||||
model.setMerName(findMerName(orderCinema.getMerId())); |
||||
if (orderCinema.getPlatformCode() != null) { |
||||
model.setPlatform(UserLoginPlatform.getDataByType(orderCinema.getPlatformCode()).getName()); |
||||
} |
||||
model.setOrderNo(orderCinema.getOrderNo()); |
||||
model.setChildOrderNo(orderCinema.getChildOrderNo()); |
||||
if (orderCinema.getPayRealPrice() == null) { |
||||
model.setPayRealPrice(new BigDecimal(0)); |
||||
} else { |
||||
model.setPayRealPrice(orderCinema.getPayRealPrice()); |
||||
} |
||||
if (orderCinema.getPayType() != null) { |
||||
model.setPayType(OrderPayTypeEnum.getData(orderCinema.getPayType()).getName()); |
||||
} else { |
||||
model.setPayType("未知"); |
||||
} |
||||
|
||||
model.setFinishTime(DateUtil.date2String(orderCinema.getCreateTime() , DateUtil.Y_M_D_HMS)); |
||||
list.add(model); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
// 整合星巴克订单
|
||||
private List<MerOrderSettlementDetailModel> starbucksOrder(Map<String, Object> map, List<MerOrderSettlementDetailModel> list) { |
||||
// 查询星巴克
|
||||
List<BsOrderStarbucks> orderStarbucksList = starbucksService.getListFinish(map); |
||||
MerOrderSettlementDetailModel model; |
||||
for (BsOrderStarbucks orderStarbucks : orderStarbucksList) { |
||||
model = new MerOrderSettlementDetailModel(); |
||||
model.setBusinessType("星巴克订单"); |
||||
model.setGoodsName(orderStarbucks.getName()); |
||||
model.setMerName(findMerName(orderStarbucks.getMerId())); |
||||
if (orderStarbucks.getPlatformCode() != null) { |
||||
model.setPlatform(UserLoginPlatform.getDataByType(orderStarbucks.getPlatformCode()).getName()); |
||||
} |
||||
model.setOrderNo(orderStarbucks.getOrderNo()); |
||||
model.setChildOrderNo(orderStarbucks.getChildOrderNo()); |
||||
if (orderStarbucks.getPrice() == null) { |
||||
model.setPayRealPrice(new BigDecimal(0)); |
||||
} else { |
||||
model.setPayRealPrice(orderStarbucks.getPrice()); |
||||
} |
||||
if (orderStarbucks.getPayType() != null) { |
||||
model.setPayType(OrderPayTypeEnum.getData(orderStarbucks.getPayType()).getName()); |
||||
} else { |
||||
model.setPayType("未知"); |
||||
} |
||||
model.setFinishTime(DateUtil.date2String(orderStarbucks.getCreateTime() , DateUtil.Y_M_D_HMS)); |
||||
list.add(model); |
||||
} |
||||
return list; |
||||
} |
||||
// 整合美团订单
|
||||
private List<MerOrderSettlementDetailModel> meiTuanOrder(Map<String, Object> map, List<MerOrderSettlementDetailModel> list) { |
||||
// 查询美团订单
|
||||
List<BsOrderMeituan> orderMeituanList = meiTuanService.getOrderListFinish(map); |
||||
MerOrderSettlementDetailModel model; |
||||
for (BsOrderMeituan orderMeiTuan : orderMeituanList) { |
||||
model = new MerOrderSettlementDetailModel(); |
||||
model.setBusinessType("美团订单"); |
||||
model.setBusiness(orderMeiTuan.getSqtBizOrderId()); |
||||
model.setGoodsName(orderMeiTuan.getGoodsName()); |
||||
model.setMerName(findMerName(orderMeiTuan.getMerId())); |
||||
if (orderMeiTuan.getPlatformCode() != null) { |
||||
model.setPlatform(UserLoginPlatform.getDataByType(orderMeiTuan.getPlatformCode()).getName()); |
||||
} |
||||
model.setOrderNo(orderMeiTuan.getOrderNo()); |
||||
model.setChildOrderNo(orderMeiTuan.getChildOrderNo()); |
||||
if (orderMeiTuan.getPayRealPrice() == null) { |
||||
model.setPayRealPrice(new BigDecimal(0)); |
||||
} else { |
||||
model.setPayRealPrice(orderMeiTuan.getPayRealPrice()); |
||||
} |
||||
if (orderMeiTuan.getPayType() != null) { |
||||
model.setPayType(OrderPayTypeEnum.getData(orderMeiTuan.getPayType()).getName()); |
||||
} else { |
||||
model.setPayType("未知"); |
||||
} |
||||
if (orderMeiTuan.getFinishTime() != null) { |
||||
model.setFinishTime(DateUtil.date2String(orderMeiTuan.getFinishTime() , DateUtil.Y_M_D_HMS)); |
||||
} else { |
||||
model.setFinishTime(DateUtil.date2String(orderMeiTuan.getUpdateTime() , DateUtil.Y_M_D_HMS)); |
||||
} |
||||
list.add(model); |
||||
} |
||||
return list; |
||||
} |
||||
// 整合会员订单
|
||||
private List<MerOrderSettlementDetailModel> membersOrder(Map<String, Object> map, List<MerOrderSettlementDetailModel> list) { |
||||
// 查询会员订单
|
||||
List<BsOrderMember> orderMembersList = memberService.getListFinish(map); |
||||
MerOrderSettlementDetailModel model; |
||||
for (BsOrderMember orderMember : orderMembersList) { |
||||
model = new MerOrderSettlementDetailModel(); |
||||
model.setBusinessType("会员订单"); |
||||
model.setGoodsName(orderMember.getGoodsName()); |
||||
model.setMerName(findMerName(orderMember.getMerId())); |
||||
if (orderMember.getPlatformCode() != null) { |
||||
model.setPlatform(UserLoginPlatform.getDataByType(orderMember.getPlatformCode()).getName()); |
||||
} |
||||
model.setOrderNo(orderMember.getOrderNo()); |
||||
model.setChildOrderNo(orderMember.getChildOrderNo()); |
||||
if (orderMember.getPayRealPrice() == null) { |
||||
model.setPayRealPrice(new BigDecimal(0)); |
||||
} else { |
||||
model.setPayRealPrice(orderMember.getPayRealPrice()); |
||||
} |
||||
if (orderMember.getPayType() != null) { |
||||
model.setPayType(OrderPayTypeEnum.getData(orderMember.getPayType()).getName()); |
||||
} else { |
||||
model.setPayType("未知"); |
||||
} |
||||
if (orderMember.getFinishTime() != null) { |
||||
model.setFinishTime(DateUtil.date2String(orderMember.getFinishTime() , DateUtil.Y_M_D_HMS)); |
||||
} else { |
||||
model.setFinishTime(DateUtil.date2String(orderMember.getUpdateTime() , DateUtil.Y_M_D_HMS)); |
||||
} |
||||
list.add(model); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
|
||||
private String findMerName(Long merId) { |
||||
// 查询商户
|
||||
List<BsMer> bsMerList = bsMerService.getList(new HashMap<>()); |
||||
|
||||
bsMerList = bsMerList.stream().filter(s -> s.getId().equals(merId)).collect(Collectors.toList()); |
||||
|
||||
if (bsMerList.size() > 0) { |
||||
return bsMerList.get(0).getMerName(); |
||||
} |
||||
return merId.toString(); |
||||
} |
||||
|
||||
private String couponCode(String childOrderNo , List<OrderCouponModel> orderCouponModelList) { |
||||
|
||||
orderCouponModelList = orderCouponModelList.stream().filter(s -> s.getChildOrderNo().equals(childOrderNo)).collect(Collectors.toList()); |
||||
|
||||
if (!orderCouponModelList.isEmpty()) { |
||||
StringBuilder sb = new StringBuilder(); |
||||
|
||||
for (OrderCouponModel orderCouponModel : orderCouponModelList) { |
||||
sb.append(orderCouponModel.getCouNo()).append(","); |
||||
} |
||||
return sb.substring(0, sb.length() - 1); |
||||
} |
||||
return null; |
||||
} |
||||
} |
Loading…
Reference in new issue