Commit c20b00a3 by jinxin

运维后台接口开发

parent 22252664
package com.gic.haoban.manage.web.controller; package com.gic.haoban.manage.web.controller;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.licence.LicenceOrderDTO;
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.service.WxEnterpriseApiService;
import com.gic.haoban.manage.api.service.licence.LicenceOrderApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.licence.LicenceOrderPageQO;
import com.gic.haoban.manage.web.vo.licence.LicenceOrderPageVO;
import com.gic.haoban.manage.web.vo.licence.LicenceOrderVO;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
/** /**
* <p> * 企业微信许可账号购买
* 前端控制器
* </p>
* *
* @author jx * @author jx
* @since 2023-03-09 * @since 2023-03-09
...@@ -16,4 +45,135 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -16,4 +45,135 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/licence-order") @RequestMapping("/licence-order")
public class LicenceOrderController { public class LicenceOrderController {
private static Logger logger = LogManager.getLogger(LicenceOrderController.class);
@Autowired
private LicenceOrderApiService licenceOrderApiService;
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
/**
* 查询订单详情
*/
@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());
}
ServiceResponse<LicenceOrderDTO> licenceOrderDetail = licenceOrderApiService.getLicenceOrderDetail(orderId, null);
LicenceOrderVO licenceOrderVO = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderDetail.getResult()), LicenceOrderVO.class);
return RestResponse.successResult(licenceOrderVO);
}
/**
* 分页查询订单列表
*/
@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());
}
String enterpriseId = loginUser.getEnterpriseId();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
String clerkName = loginUser.getClerkName();
LicenceOrderPageQDTO qdto = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderPageQO), LicenceOrderPageQDTO.class);
qdto.setEnterpriseId(enterpriseId);
qdto.setWxEnterpriseId(wxEnterpriseId);
qdto.setCreatorName(clerkName);
ServiceResponse<Page<LicenceOrderPageDTO>> licenceOrderPage = licenceOrderApiService.getLicenceOrderPage(qdto);
Page<LicenceOrderPageVO> result = PageHelperUtils.changePageToCurrentPage(licenceOrderPage.getResult(), LicenceOrderPageVO.class);
return RestResponse.successResult(result);
}
/**
* 取消订单
*/
@RequestMapping("licence-order-cancel")
public RestResponse<Boolean> cancelLicenceOrder(@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());
}
String enterpriseId = loginUser.getEnterpriseId();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
String clerkName = loginUser.getClerkName();
Boolean result = licenceOrderApiService.updateLicenceOrderType(orderId, 2, enterpriseId, wxEnterpriseId, clerkName, 1).getResult();
return RestResponse.successResult(result);
}
/**
* 支付订单
*/
@RequestMapping("licence-order-pay")
public RestResponse<Boolean> 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());
}
Boolean result = licenceOrderApiService.payLicenceOrder(orderId, loginUser.getWxEnterpriseId()).getResult();
return RestResponse.successResult(result);
}
/**
* 审核订单
*/
@RequestMapping("licence-order-check")
public RestResponse<Boolean> checkLicenceOrder(@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());
}
String enterpriseId = loginUser.getEnterpriseId();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
String clerkName = loginUser.getClerkName();
Boolean result = licenceOrderApiService.updateLicenceOrderType(orderId, 2, enterpriseId, wxEnterpriseId, clerkName, 1).getResult();
return RestResponse.successResult(result);
}
/**
* 查询企业品牌名称
*/
@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());
}
HashMap<String, String> result = new HashMap<>(8);
//查询gic品牌名称
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(loginUser.getEnterpriseId());
if (ObjectUtil.isNotNull(enterpriseDTO)) {
logger.info("gic企业查询返回实体:{}", JSON.toJSONString(enterpriseDTO));
result.put("enterpriseName", enterpriseDTO.getEnterpriseName());
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(loginUser.getWxEnterpriseId());
if (ObjectUtil.isNotNull(wxEnterpriseDTO)) {
logger.info("企业微信查询返回实体:{}", JSON.toJSONString(wxEnterpriseDTO));
result.put("wxEnterpriseName", wxEnterpriseDTO.getCorpName());
}
return RestResponse.successResult(result);
}
/**
* 订单编号和企业微信订单编号模糊搜索
*
* @param param 模糊查询
* @param type 0 微信订单编号 1 企业微信订单编号
* @return
*/
@RequestMapping("get-order-id-list")
public RestResponse<List<String>> getOrderIdList(String param, 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());
}
ServiceResponse<List<String>> orderIdList = licenceOrderApiService.getOrderIdList(param, type, loginUser.getWxEnterpriseId());
return RestResponse.successResult(orderIdList.getResult());
}
} }
package com.gic.haoban.manage.web.qo.licence;
import com.gic.api.base.commons.BasePageInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author jx
* @since 2023-03-09
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class LicenceOrderPageQO extends BasePageInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 订单编号
*/
private String transactionId;
/**
* 订单状态,0:待支付,1:已支付,2:已取消,3:已过期,4:已退款,5:审核中
*/
private Integer orderStatus;
/**
* 企业微信订单id
*/
private String qywxOrderId;
/**
* 企业微信订单状态,0:待支付,1:已支付,2:已取消,3:已过期,4:退款中,5:退款被拒绝,6:已退款,7已失效
*/
private Integer qywxOrderStatus;
/**
* 订单创建开始时间
*/
private String startTime;
/**
* 订单创建结束时间
*/
private String endTime;
}
package com.gic.haoban.manage.web.qo.licence;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author jx
* @since 2023-03-09
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class LicenceOrderQO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 订单类型,1:购买帐号,2:续期帐号
*/
private Integer orderType;
/**
* 互通帐号个数
*/
private Integer externalContactCount;
// /**
// * 基础帐号个数
// */
// private Integer baseCount;
/**
* 订单金额,单位分
*/
private Integer price;
/**
* 购买时间类型 1:按月购买,2:按天购买
*/
private Integer timeType;
/**
* 购买的时间数值
*/
private Integer timeValue;
/**
* 支付类型 1在线支付 2对公转账
*/
private Integer payType;
/**
* 校验金额
*/
public Integer checkPrice(){
if (this.externalContactCount ==null || this.externalContactCount<0){
return -1;
}
Integer myPrice=0;
//根据企业微信的计费规则计算
if (this.externalContactCount<=5){
myPrice = 50*this.externalContactCount;
} else if (this.externalContactCount<=200) {
myPrice = 250+40*(this.externalContactCount-5);
} else if (this.externalContactCount<=500) {
myPrice = 8050+30*(this.externalContactCount-200);
} else if (this.externalContactCount<=1000) {
myPrice = 17050+20*(this.externalContactCount-500);
} else if (this.externalContactCount<=10000) {
myPrice = 27050+10*(this.externalContactCount-1000);
}else {
return -1;
}
//转化为分
myPrice = myPrice*this.timeValue*100;
if (this.timeType == 1){
//企业微信的规则: 12.312,最终保留的是12.32
if (myPrice%12==0){
myPrice = myPrice/12;
}else {
myPrice = myPrice/12+1;
}
}else {
if (myPrice%372==0){
myPrice = myPrice/372;
}else {
myPrice = myPrice/372+1;
}
}
if (!this.price .equals(myPrice)){
return 0;
}
return 1;
}
}
package com.gic.haoban.manage.web.vo.licence;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author jx
* @since 2023-03-09
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class LicenceOrderPageVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 订单id
*/
private Long orderId;
/**
* 订单类型,1:购买帐号,2:续期帐号
*/
private Integer orderType;
/**
* 互通帐号个数
*/
private Integer externalContactCount;
/**
* 基础帐号个数
*/
private Integer baseCount;
/**
* 订单金额,单位分
*/
private Integer price;
/**
* 购买时间类型 1:按月购买,2:按天购买
*/
private Integer timeType;
/**
* 购买的时间数值
*/
private Integer timeValue;
/**
* 支付类型 1在线支付 2对公转账
*/
private Integer payType;
/**
* 订单编号
*/
private String transactionId;
/**
* 订单状态,0:待支付,1:已支付,2:已取消,3:已过期,4:已退款,5:审核中
*/
private Integer orderStatus;
/**
* 订单状态更改原因
*/
private String orderStatusReason;
/**
* 支付时间 支付类型为1:微信支付时间 2:审核确认通过的时间
*/
private Date payTime;
/**
* 企业微信订单id
*/
private String qywxOrderId;
/**
* 企业微信订单状态,0:待支付,1:已支付,2:已取消,3:已过期,4:退款中,5:退款被拒绝,6:已退款,7已失效
*/
private Integer qywxOrderStatus;
/**
* 企业微信订单更改原因
*/
private String qywxOrderStatusReason;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private String creatorId;
/**
* 创建人名称
*/
private String creatorName;
}
package com.gic.haoban.manage.web.vo.licence;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author jx
* @since 2023-03-09
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class LicenceOrderProgressVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
private Long id;
/**
* 订单状态
*/
private String orderStatus;
/**
* 标记字段 1好办后台
*/
private Integer type;
/**
* 上传凭证url
*/
private String voucher;
/**
* 原因
*/
private String reason;
/**
* 创建时间
*/
private Date createTime;
}
package com.gic.haoban.manage.web.vo.licence;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author jx
* @since 2023-03-09
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class LicenceOrderVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 订单id
*/
private Long orderId;
/**
* gic商户Id
*/
private String enterpriseId;
/**
* gic品牌名称
*/
private String enterpriseName;
/**
* wx企业Id
*/
private String wxEnterpriseId;
/**
* 微信商户名称
*/
private String wxEnterpriseName;
/**
* 订单类型,1:购买帐号,2:续期帐号
*/
private Integer orderType;
/**
* 互通帐号个数
*/
private Integer externalContactCount;
/**
* 基础帐号个数
*/
private Integer baseCount;
/**
* 订单金额,单位分
*/
private Integer price;
/**
* 购买时间类型 1:按月购买,2:按天购买
*/
private Integer timeType;
/**
* 购买的时间数值
*/
private Integer timeValue;
/**
* 支付类型 1在线支付 2对公转账
*/
private Integer payType;
/**
* 订单编号
*/
private String transactionId;
/**
* 上传凭证url
*/
private String voucher;
/**
* 订单状态,0:待支付,1:已支付,2:已取消,3:已过期,4:已退款,5:审核中
*/
private Integer orderStatus;
/**
* 订单状态更改原因
*/
private String orderStatusReason;
/**
* 支付时间 支付类型为1:微信支付时间 2:上传凭证时间
*/
private Date payTime;
/**
* 退款时间
*/
private Date refundTime;
/**
* 企业微信订单id
*/
private String qywxOrderId;
/**
* 企业微信订单状态,0:待支付,1:已支付,2:已取消,3:已过期,4:退款中,5:退款被拒绝,6:已退款,7已失效
*/
private Integer qywxOrderStatus;
/**
* 企业微信订单更改原因
*/
private String qywxOrderStatusReason;
/**
* 企业微信支付时间
*/
private Date qywxPayTime;
/**
* 企业微信退款时间
*/
private Date qywxRefundTime;
/**
* 审核不通过原因
*/
private String reason;
/**
* 创建时间
*/
private Date createTime;
/**
* 到期时间
*/
private Date expireTime;
/**
* 当前时间
*/
private Date nowTime;
/**
* 订单进度list
*/
private List<LicenceOrderProgressVO> OrderProgressList;
}
...@@ -67,4 +67,5 @@ ...@@ -67,4 +67,5 @@
<dubbo:reference interface="com.gic.haoban.manage.api.service.fee.HaobanQywxFeeApiService" id="haobanQywxFeeApiService"/> <dubbo:reference interface="com.gic.haoban.manage.api.service.fee.HaobanQywxFeeApiService" id="haobanQywxFeeApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.role.HaobanRoleApiService" id="haobanRoleApiService"/> <dubbo:reference interface="com.gic.haoban.manage.api.service.role.HaobanRoleApiService" id="haobanRoleApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.role.HaobanMenuApiService" id="haobanMenuApiService"/> <dubbo:reference interface="com.gic.haoban.manage.api.service.role.HaobanMenuApiService" id="haobanMenuApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.licence.LicenceOrderApiService" id="licenceOrderApiService"/>
</beans> </beans>
...@@ -193,7 +193,7 @@ ...@@ -193,7 +193,7 @@
<update id="uploadLicenceOrderVoucher"> <update id="uploadLicenceOrderVoucher">
UPDATE tab_haoban_licence_order UPDATE tab_haoban_licence_order
SET voucher = #{voucher} ,update_time = now() SET voucher = #{voucher} ,update_time = now(),pay_time = now()
WHERE order_id = #{orderId} WHERE order_id = #{orderId}
and delete_flag = 0 and delete_flag = 0
</update> </update>
......
...@@ -41,4 +41,8 @@ public class LicenceOrderServiceTest { ...@@ -41,4 +41,8 @@ public class LicenceOrderServiceTest {
ServiceResponse<LicenceOrderDTO> licenceOrderDetail = licenceOrderApiService.getLicenceOrderDetail(1L, null); ServiceResponse<LicenceOrderDTO> licenceOrderDetail = licenceOrderApiService.getLicenceOrderDetail(1L, null);
} }
@Test
public void test4(){
ServiceResponse<Boolean> result = licenceOrderApiService.payLicenceOrder(512360219787935783L, "ca66a01b79474c40b3e7c7f93daf1a3b");
}
} }
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