Commit d01122a2 by jinxin

bug处理

parent ca886b87
......@@ -7,6 +7,8 @@ import com.gic.haoban.manage.api.dto.licence.LicenceOrderPageDTO;
import com.gic.haoban.manage.api.dto.qdto.licence.LicenceOrderPageQDTO;
import com.gic.haoban.manage.api.dto.qdto.licence.LicenceOrderQDTO;
import java.util.Date;
/**
* <p>
* 服务类
......@@ -100,7 +102,7 @@ public interface LicenceOrderApiService {
* @param wxOrderId 微信支付id
* @return
*/
ServiceResponse<Boolean> saveTransactionCode(Long orderId, String transactionCode, String prepayId, String wxOrderId);
ServiceResponse<Boolean> saveTransactionCode(Long orderId, String transactionCode, String prepayId, String wxOrderId, Date payTime);
}
......@@ -4,6 +4,8 @@ import com.gic.haoban.manage.api.dto.qdto.licence.LicenceOrderPageQDTO;
import com.gic.haoban.manage.service.entity.licence.TabHaobanLicenceOrder;
import org.apache.ibatis.annotations.Param;
import javax.xml.crypto.Data;
import java.util.Date;
import java.util.List;
/**
......@@ -84,7 +86,8 @@ public interface TabHaobanLicenceOrderMapper {
List<TabHaobanLicenceOrder> getLicenceOrderPage(LicenceOrderPageQDTO licenceOrderPageQDTO);
Integer saveTransactionCode(@Param("orderId") Long orderId, @Param("transactionCode") String transactionCode, @Param("prepayId") String prepayId, @Param("wxOrderId") String wxOrderId);
Integer saveTransactionCode(@Param("orderId") Long orderId, @Param("transactionCode") String transactionCode,
@Param("prepayId") String prepayId, @Param("wxOrderId") String wxOrderId, @Param("payTime") Date payTime);
/**
* 获取订单详情
......
......@@ -7,6 +7,8 @@ import com.gic.haoban.manage.api.dto.qdto.licence.LicenceOrderQDTO;
import com.gic.haoban.manage.service.entity.licence.TabHaobanLicenceOrder;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
/**
* <p>
* 企业微信许可账号购买
......@@ -84,7 +86,7 @@ public interface LicenceOrderService {
* @param wxOrderId 微信支付id
* @return
*/
Integer saveTransactionCode(Long orderId, String transactionCode, String prepayId, String wxOrderId);
Integer saveTransactionCode(Long orderId, String transactionCode, String prepayId, String wxOrderId, Date payTime);
/**
* 查询微信订单详情
......
......@@ -66,6 +66,8 @@ public class LicenceOrderServiceImpl implements LicenceOrderService {
TabHaobanLicenceOrder order = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderQDTO), TabHaobanLicenceOrder.class);
Date now = new Date();
order.setOrderId(orderId);
//默认支付状态为待支付
order.setOrderStatus(0);
order.setCreateTime(now);
order.setUpdateTime(now);
Date expireTime;
......@@ -208,8 +210,8 @@ public class LicenceOrderServiceImpl implements LicenceOrderService {
}
@Override
public Integer saveTransactionCode(Long orderId, String transactionCode, String prepayId, String wxOrderId) {
return tabHaobanLicenceOrderMapper.saveTransactionCode(orderId,transactionCode,prepayId,wxOrderId);
public Integer saveTransactionCode(Long orderId, String transactionCode, String prepayId, String wxOrderId,Date payTime) {
return tabHaobanLicenceOrderMapper.saveTransactionCode(orderId,transactionCode,prepayId,wxOrderId,payTime);
}
@Override
......
......@@ -174,11 +174,21 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
String orderId = object.getString("orderId");
String transactionId = object.getString("transactionId");
String timeEnd = object.getString("timeEnd");
TabHaobanLicenceOrder licenceOrder = licenceOrderService.selectByTransactionId(transactionId);
TabHaobanLicenceOrder licenceOrder = licenceOrderService.selectByTransactionId(orderId);
if (licenceOrder == null){
logger.info("微信回调的订单编号:{}异常!!",orderId);
return ServiceResponse.success(false);
}
if (licenceOrder.getOrderStatus() == 1){
//微信会多次回调
logger.info("微信回调的订单已处理!");
return ServiceResponse.success(false);
}
Date payTime = DateUtil.strToDate(DateUtil.FORMAT_DATETIME_14, timeEnd);
//更新订单状态
licenceOrderService.updateLicenceOrderType(licenceOrder.getOrderId(),1,licenceOrder.getEnterpriseId(),licenceOrder.getWxEnterpriseId(),"系统",1);
//保存微信订单id
licenceOrderService.saveTransactionCode(licenceOrder.getOrderId(), null,null,orderId);
licenceOrderService.saveTransactionCode(licenceOrder.getOrderId(), null,null,transactionId,payTime);
//生成企业微信订单
// payLicenceOrder(licenceOrder.getOrderId(),licenceOrder.getWxEnterpriseId());
//查询gic品牌名称
......@@ -225,8 +235,8 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
}
@Override
public ServiceResponse<Boolean> saveTransactionCode(Long orderId, String transactionCode, String prepayId, String wxOrderId) {
licenceOrderService.saveTransactionCode(orderId,transactionCode,prepayId,wxOrderId);
public ServiceResponse<Boolean> saveTransactionCode(Long orderId, String transactionCode, String prepayId, String wxOrderId,Date payTime) {
licenceOrderService.saveTransactionCode(orderId,transactionCode,prepayId,wxOrderId,payTime);
return ServiceResponse.success(true);
}
}
......@@ -243,6 +243,9 @@
<if test="wxOrderId != null">
wx_order_id = #{wxOrderId},
</if>
<if test="payTime != null">
pay_time = #{payTime},
</if>
update_time = now()
WHERE order_id = #{orderId}
and delete_flag = 0
......
......@@ -28,11 +28,9 @@ import com.gic.haoban.manage.web.qo.licence.LicenceOrderPageQO;
import com.gic.haoban.manage.web.qo.licence.LicenceOrderQO;
import com.gic.haoban.manage.web.vo.licence.LicenceOrderPageVO;
import com.gic.haoban.manage.web.vo.licence.LicenceOrderVO;
import com.gic.marketing.api.service.EnterpriseAccountInfoApiService;
import com.gic.thirdparty.api.dto.ScanPayReqDataDTO;
import com.gic.thirdparty.api.dto.ScanPayResDataDTO;
import com.gic.thirdparty.api.service.Pay4WXService;
import com.gic.thirdparty.api.service.RechargeCenterService;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -49,6 +47,7 @@ import java.util.Map;
/**
* 企业微信许可账号购买
*
* @author jx
* @since 2023-03-09
*/
......@@ -68,46 +67,49 @@ public class LicenceOrderController {
private Pay4WXService pay4WXService;
@Autowired
private Config config;
/**
* 查询订单详情
*/
@RequestMapping("licence-order-detail")
public RestResponse<LicenceOrderVO> getLicenceOrderDetail(@RequestParam Long orderId) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())){
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()),HaoBanErrCode.ERR_4.getMsg());
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg());
}
ServiceResponse<LicenceOrderDTO> licenceOrderDetail = licenceOrderApiService.getLicenceOrderDetail(orderId,1);
ServiceResponse<LicenceOrderDTO> licenceOrderDetail = licenceOrderApiService.getLicenceOrderDetail(orderId, 1);
LicenceOrderVO licenceOrderVO = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderDetail.getResult()), LicenceOrderVO.class);
return RestResponse.successResult(licenceOrderVO);
}
/**
* 删除订单
*/
@RequestMapping("licence-order-delete")
public RestResponse<Boolean> deleteLicenceOrder(@RequestParam Long orderId) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())){
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()),HaoBanErrCode.ERR_4.getMsg());
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg());
}
ServiceResponse<Boolean> booleanServiceResponse = licenceOrderApiService.deleteLicenceOrder(orderId);
return RestResponse.successResult(booleanServiceResponse.getResult());
}
/**
* 新增或者修改订单
*/
@RequestMapping("licence-order-saveOrUpdate")
public RestResponse<String> saveOrUpdateLicenceOrder(@RequestBody LicenceOrderQO licenceOrderQO) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())){
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()),HaoBanErrCode.ERR_4.getMsg());
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg());
}
//金额校验
Integer integer = licenceOrderQO.checkPrice();
if (integer==-1){
return RestResponse.failure("-9999","许可账号数量有误!");
} else if (integer==0) {
return RestResponse.failure("-9999","购买金额计算有误!");
if (integer == -1) {
return RestResponse.failure("-9999", "许可账号数量有误!");
} else if (integer == 0) {
return RestResponse.failure("-9999", "购买金额计算有误!");
}
LicenceOrderQDTO licenceOrderQDTO = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderQO), LicenceOrderQDTO.class);
licenceOrderQDTO.setEnterpriseId(loginUser.getEnterpriseId());
......@@ -117,14 +119,15 @@ public class LicenceOrderController {
String result = licenceOrderApiService.saveOrUpdateLicenceOrder(licenceOrderQDTO).getResult();
return RestResponse.successResult(result);
}
/**
* 分页查询订单列表
*/
@RequestMapping("licence-order-page")
public RestResponse<Page<LicenceOrderPageVO>> getLicenceOrderPage(@RequestBody LicenceOrderPageQO licenceOrderPageQO) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())){
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()),HaoBanErrCode.ERR_4.getMsg());
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg());
}
String enterpriseId = loginUser.getEnterpriseId();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
......@@ -137,51 +140,54 @@ public class LicenceOrderController {
Page<LicenceOrderPageVO> result = PageHelperUtils.changePageToCurrentPage(licenceOrderPage.getResult(), LicenceOrderPageVO.class);
return RestResponse.successResult(result);
}
/**
* 取消订单/订单已经过期
*/
@RequestMapping("licence-order-cancel")
public RestResponse<Boolean> cancelLicenceOrder(@RequestParam Long orderId,Integer type) {
public RestResponse<Boolean> cancelLicenceOrder(@RequestParam Long orderId, Integer type) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())){
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()),HaoBanErrCode.ERR_4.getMsg());
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg());
}
String enterpriseId = loginUser.getEnterpriseId();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
String clerkName = loginUser.getClerkName();
Boolean result = licenceOrderApiService.updateLicenceOrderType(orderId, type,enterpriseId,wxEnterpriseId,clerkName,1).getResult();
Boolean result = licenceOrderApiService.updateLicenceOrderType(orderId, type, enterpriseId, wxEnterpriseId, clerkName, 1).getResult();
return RestResponse.successResult(result);
}
/**
* 订单凭证上传
*/
@RequestMapping("licence-order-voucher-upload")
public RestResponse<Boolean> uploadLicenceOrderVoucher(@RequestParam Long orderId,String voucher) {
public RestResponse<Boolean> uploadLicenceOrderVoucher(@RequestParam Long orderId, String voucher) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())){
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()),HaoBanErrCode.ERR_4.getMsg());
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg());
}
String enterpriseId = loginUser.getEnterpriseId();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
String clerkName = loginUser.getClerkName();
Boolean result = licenceOrderApiService.uploadLicenceOrderVoucher(orderId, voucher,enterpriseId,wxEnterpriseId,clerkName).getResult();
Boolean result = licenceOrderApiService.uploadLicenceOrderVoucher(orderId, voucher, enterpriseId, wxEnterpriseId, clerkName).getResult();
return RestResponse.successResult(result);
}
/**
* 支付订单
*/
@RequestMapping("licence-order-pay-1")
public RestResponse<Map<String, Object>> payLicenceOrder(@RequestParam Long orderId) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())){
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()),HaoBanErrCode.ERR_4.getMsg());
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg());
}
LicenceOrderDTO result = licenceOrderApiService.getLicenceOrderDetail(orderId, 1).getResult();
if (result == null){
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_5.getCode()),HaoBanErrCode.ERR_5.getMsg());
if (result == null) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_5.getCode()), HaoBanErrCode.ERR_5.getMsg());
}
Integer money = result.getPrice();
if(null != loginUser.getPhoneNumber() && Arrays.asList("13456789987","13429152802").contains(loginUser.getPhoneNumber())) {
if (null != loginUser.getPhoneNumber() && Arrays.asList("13456789987", "13429152802").contains(loginUser.getPhoneNumber())) {
//测试账号付款一分
money = 1;
}
......@@ -197,37 +203,38 @@ public class LicenceOrderController {
int lastIndex = host.lastIndexOf("/");
// 倒数第二个分隔符位置
int secondLastIndex = host.lastIndexOf("/", lastIndex - 1);
String subHost = host.substring(0, secondLastIndex+1);
String url = subHost+"gic-thirdparty/weixin_payment_result_notice_qywx";
String subHost = host.substring(0, secondLastIndex + 1);
String url = subHost + "gic-thirdparty/weixin_payment_result_notice_qywx";
scanPayReqData.setNotify_url(url);
ScanPayResDataDTO prePaymentOrderForQYWX = pay4WXService.createPrePaymentOrderForQYWX(scanPayReqData);
logger.info("微信预支付返回信息:{}",JSON.toJSONString(prePaymentOrderForQYWX));
if(prePaymentOrderForQYWX == null){
logger.info("微信预支付返回信息:{}", JSON.toJSONString(prePaymentOrderForQYWX));
if (prePaymentOrderForQYWX == null) {
logger.info("微信预支付订单二维码生成失败!!");
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_100034.getCode()),HaoBanErrCode.ERR_100034.getMsg());
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_100034.getCode()), HaoBanErrCode.ERR_100034.getMsg());
}
Map<String, Object> map = new HashMap<String, Object>();
map.put("transactionCode", transactionCode);
map.put("url", prePaymentOrderForQYWX.getCode_url());
map.put("money",money);
map.put("money", money);
//记录订单号transactionCode和预支付交易会话标识
licenceOrderApiService.saveTransactionCode(orderId,transactionCode,prePaymentOrderForQYWX.getPrepay_id(),null);
licenceOrderApiService.saveTransactionCode(orderId, transactionCode, prePaymentOrderForQYWX.getPrepay_id(), null, null);
return RestResponse.successResult(map);
}
/**
* 支付订单-判断是否支付成功
*/
@RequestMapping("licence-order-pay-2")
public RestResponse<Boolean> payLicenceOrder2(@RequestParam Long orderId) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())){
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()),HaoBanErrCode.ERR_4.getMsg());
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg());
}
LicenceOrderDTO result = licenceOrderApiService.getLicenceOrderDetail(orderId, 1).getResult();
if (result == null){
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_5.getCode()),HaoBanErrCode.ERR_5.getMsg());
if (result == null) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_5.getCode()), HaoBanErrCode.ERR_5.getMsg());
}
if (result.getOrderStatus() == 1){
if (result.getOrderStatus() == 1) {
return RestResponse.successResult(true);
}
return RestResponse.successResult(false);
......@@ -239,31 +246,32 @@ public class LicenceOrderController {
@RequestMapping("get-enterprise-name")
public RestResponse<HashMap<String, String>> getEnterpriseName() {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())){
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()),HaoBanErrCode.ERR_4.getMsg());
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg());
}
HashMap<String, String> result = new HashMap<>(8);
//查询gic品牌名称
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(loginUser.getEnterpriseId());
if (ObjectUtil.isNotNull(enterpriseDTO)){
if (ObjectUtil.isNotNull(enterpriseDTO)) {
logger.info("gic企业查询返回实体:{}", JSON.toJSONString(enterpriseDTO));
result.put("enterpriseName",enterpriseDTO.getEnterpriseName());
result.put("enterpriseName", enterpriseDTO.getEnterpriseName());
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(loginUser.getWxEnterpriseId());
if (ObjectUtil.isNotNull(wxEnterpriseDTO)){
if (ObjectUtil.isNotNull(wxEnterpriseDTO)) {
logger.info("企业微信查询返回实体:{}", JSON.toJSONString(wxEnterpriseDTO));
result.put("wxEnterpriseName",wxEnterpriseDTO.getCorpName());
result.put("wxEnterpriseName", wxEnterpriseDTO.getCorpName());
}
return RestResponse.successResult(result);
}
/**
* 查询企业是否存在未支付订单
*/
@RequestMapping("licence-order-isPay")
public RestResponse<String> isPayLicenceOrder() {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())){
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()),HaoBanErrCode.ERR_4.getMsg());
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg());
}
ServiceResponse<String> payLicenceOrder = licenceOrderApiService.isPayLicenceOrder(loginUser.getWxEnterpriseId());
return RestResponse.successResult(payLicenceOrder.getResult());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment