Commit 4699ee19 by jinxin

企业微信许可账号购买

parent 163e4e7c
......@@ -56,7 +56,7 @@ public interface LicenceOrderApiService {
* @param type 订单状态
* @return
*/
ServiceResponse<Boolean> cancelLicenceOrder(Long orderId, Integer type);
ServiceResponse<Boolean> updateLicenceOrderType(Long orderId, Integer type);
/**
* 订单凭证上传
......
......@@ -34,4 +34,20 @@ public interface TabHaobanLicenceOrderMapper {
*/
Integer deleteById(@Param("orderId") Long orderId);
/**
* 跟新订单状态
* @param orderId
* @param type
* @return
*/
Integer updateLicenceOrderType(@Param("orderId") Long orderId,@Param("type") Integer type);
/**
* 上次订单支付凭证
* @param orderId
* @param voucher
* @return
*/
Integer uploadLicenceOrderVoucher(@Param("orderId")Long orderId, @Param("voucher")String voucher);
}
......@@ -34,6 +34,22 @@ public interface LicenceOrderService {
*/
void saveOrUpdateLicenceOrder(LicenceOrderQDTO licenceOrderQDTO);
/**
* 更新订单状态
* @param orderId 订单id
* @param type 订单状态
* @return
*/
Boolean updateLicenceOrderType(Long orderId, Integer type);
/**
* 上次订单支付凭证
* @param orderId 订单id
* @param voucher 凭证url
* @return
*/
Boolean uploadLicenceOrderVoucher(Long orderId, String voucher);
}
package com.gic.haoban.manage.service.service.licence.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.UniqueIdUtils;
......@@ -40,29 +41,43 @@ public class LicenceOrderServiceImpl implements LicenceOrderService {
@Override
@Transactional(rollbackFor = Exception.class)
public void saveOrUpdateLicenceOrder(LicenceOrderQDTO licenceOrderQDTO) {
TabHaobanLicenceOrder order = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderQDTO), TabHaobanLicenceOrder.class);
Date now = new Date();
long orderId = UniqueIdUtils.uniqueLong();
order.setOrderId(orderId);
order.setCreateTime(now);
order.setUpdateTime(now);
if (order.getPayType()==1){
Date expireTime = DateUtil.addNumForMinute(now, 30);
order.setExpireTime(expireTime);
}else {
Date expireTime = DateUtil.addDay(now,3);
if(ObjectUtil.isNull(licenceOrderQDTO.getOrderId())){
//订单不支持修改,只能新增
TabHaobanLicenceOrder order = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderQDTO), TabHaobanLicenceOrder.class);
Date now = new Date();
long orderId = UniqueIdUtils.uniqueLong();
order.setOrderId(orderId);
order.setCreateTime(now);
order.setUpdateTime(now);
Date expireTime;
if(order.getPayType()==1){
expireTime = DateUtil.addNumForMinute(now, 30);
}else {
expireTime = DateUtil.addDay(now, 3);
}
order.setExpireTime(expireTime);
tabHaobanLicenceOrderMapper.insert(order);
//记录订单进度
TabHaobanLicenceOrderProgress orderProgress = new TabHaobanLicenceOrderProgress();
orderProgress.setId(UniqueIdUtils.uniqueLong());
orderProgress.setEnterpriseId(licenceOrderQDTO.getEnterpriseId());
orderProgress.setWxEnterpriseId(licenceOrderQDTO.getWxEnterpriseId());
orderProgress.setOrderId(orderId);
orderProgress.setOrderStatus("创建订单");
orderProgress.setType(1);
orderProgress.setCreatorName(licenceOrderQDTO.getCreatorName());
tabHaobanLicenceOrderProgressMapper.insert(orderProgress);
}
tabHaobanLicenceOrderMapper.insert(order);
//记录订单进度
TabHaobanLicenceOrderProgress orderProgress = new TabHaobanLicenceOrderProgress();
orderProgress.setId(UniqueIdUtils.uniqueLong());
orderProgress.setEnterpriseId(licenceOrderQDTO.getEnterpriseId());
orderProgress.setWxEnterpriseId(licenceOrderQDTO.getWxEnterpriseId());
orderProgress.setOrderId(orderId);
orderProgress.setOrderStatus("创建订单");
orderProgress.setType(1);
orderProgress.setCreatorName(licenceOrderQDTO.getCreatorName());
tabHaobanLicenceOrderProgressMapper.insert(orderProgress);
}
@Override
public Boolean updateLicenceOrderType(Long orderId, Integer type) {
return null;
}
@Override
public Boolean uploadLicenceOrderVoucher(Long orderId, String voucher) {
return null;
}
}
package com.gic.haoban.manage.service.service.out.impl.licence;
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.EntityUtil;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
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.licence.LicenceOrderProgressDTO;
import com.gic.haoban.manage.api.dto.qdto.licence.LicenceOrderPageQDTO;
import com.gic.haoban.manage.api.dto.qdto.licence.LicenceOrderQDTO;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.api.service.licence.LicenceOrderApiService;
import com.gic.haoban.manage.service.entity.licence.TabHaobanLicenceOrder;
import com.gic.haoban.manage.service.entity.licence.TabHaobanLicenceOrderProgress;
import com.gic.haoban.manage.service.service.licence.LicenceOrderProgressService;
import com.gic.haoban.manage.service.service.licence.LicenceOrderService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
......@@ -26,11 +34,19 @@ import java.util.List;
*/
public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
private static final Logger logger = LogManager.getLogger(LicenceOrderApiServiceImpl.class);
@Autowired
private LicenceOrderService licenceOrderService;
@Autowired
private LicenceOrderProgressService licenceOrderProgressService;
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Override
public ServiceResponse<LicenceOrderDTO> getLicenceOrderDetail(Long orderId) {
TabHaobanLicenceOrder licenceOrderDetail = licenceOrderService.getLicenceOrderDetail(orderId);
......@@ -39,6 +55,16 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
LicenceOrderDTO licenceOrderDTO = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderDetail), LicenceOrderDTO.class);
List<TabHaobanLicenceOrderProgress> list = licenceOrderProgressService.getListByOrderId(orderId);
licenceOrderDTO.setOrderProgressList(EntityUtil.changeEntityListByJSON(LicenceOrderProgressDTO.class, list));
//查询gic品牌名称
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(licenceOrderDTO.getEnterpriseId());
if (ObjectUtil.isNotNull(enterpriseDTO)){
licenceOrderDTO.setEnterpriseName(enterpriseDTO.getEnterpriseName());
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(licenceOrderDTO.getWxEnterpriseId());
if (ObjectUtil.isNotNull(wxEnterpriseDTO)){
logger.info("企业微信查询返回实体:{}", JSON.toJSONString(wxEnterpriseDTO));
licenceOrderDTO.setWxEnterpriseName(wxEnterpriseDTO.getCorpName());
}
return ServiceResponse.success(licenceOrderDTO);
}
return ServiceResponse.success();
......@@ -54,10 +80,7 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
@Override
public ServiceResponse<Boolean> saveOrUpdateLicenceOrder(LicenceOrderQDTO licenceOrderQDTO) {
if (licenceOrderQDTO.getOrderId()==null){
//目前只有新增
licenceOrderService.saveOrUpdateLicenceOrder(licenceOrderQDTO);
}
licenceOrderService.saveOrUpdateLicenceOrder(licenceOrderQDTO);
return ServiceResponse.success(true);
}
......@@ -67,7 +90,7 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
}
@Override
public ServiceResponse<Boolean> cancelLicenceOrder(Long orderId, Integer type) {
public ServiceResponse<Boolean> updateLicenceOrderType(Long orderId, Integer type) {
return null;
}
......
......@@ -2,17 +2,23 @@ package com.gic.haoban.manage.web.controller.licence;
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.dto.qdto.licence.LicenceOrderQDTO;
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;
......@@ -28,6 +34,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
/**
* 企业微信许可账号购买
* @author jx
......@@ -41,6 +49,10 @@ public class LicenceOrderController {
@Autowired
private LicenceOrderApiService licenceOrderApiService;
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
/**
* 查询订单详情
......@@ -76,6 +88,13 @@ public class LicenceOrderController {
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","购买金额计算有误!");
}
LicenceOrderQDTO licenceOrderQDTO = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderQO), LicenceOrderQDTO.class);
licenceOrderQDTO.setEnterpriseId(loginUser.getEnterpriseId());
licenceOrderQDTO.setWxEnterpriseId(loginUser.getWxEnterpriseId());
......@@ -107,7 +126,7 @@ public class LicenceOrderController {
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())){
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()),HaoBanErrCode.ERR_4.getMsg());
}
Boolean result = licenceOrderApiService.cancelLicenceOrder(orderId, type).getResult();
Boolean result = licenceOrderApiService.updateLicenceOrderType(orderId, type).getResult();
return RestResponse.successResult(result);
}
/**
......@@ -134,5 +153,29 @@ public class LicenceOrderController {
Boolean result = licenceOrderApiService.payLicenceOrder(orderId).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);
}
}
......@@ -52,4 +52,33 @@ public class LicenceOrderQO implements Serializable {
* 支付类型 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;
}
//单位是分
if (this.price != myPrice*100){
return 0;
}
return 1;
}
}
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