Commit 9f5218ec by 陶光胜

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-platform-enterprise into developer
parents 5003241d 4bc2f1ca
......@@ -42,6 +42,27 @@
<version>1.18.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2</version>
</dependency>
</dependencies>
<build>
......
package com.gic.enterprise.constant;
import org.apache.commons.lang3.StringUtils;
/**
* @author zhiwj
* @Description: 短信消费应用场景
......@@ -46,7 +44,7 @@ public enum SmsAppEnum {
}
public static String getNameByCode(String code) {
if (StringUtils.isNotBlank(code)) {
if (code != null) {
for (SmsAppEnum smsApp : values()) {
if (smsApp.code.equals(code)) {
return smsApp.name;
......
......@@ -111,6 +111,32 @@ public class EnterpriseDTO implements Serializable{
*/
private List<EnterpriseResourceRelDTO> resourcesList;
/***超级管理员*/
private String userName;
/**
* 手机号
*/
private String phoneNumber;
/**
* 密码
*/
private String password;
/**
* 1:自动生成 2:自定义密码
*/
private Integer passwordType;
/**
* 确认密码
*/
private String confirmPassword;
/**
* 国际区号,如中国 86
*/
private String phoneAreaCode;
public Integer getEnterpriseId() {
return enterpriseId;
}
......@@ -238,4 +264,58 @@ public class EnterpriseDTO implements Serializable{
public void setResourcesList(List<EnterpriseResourceRelDTO> resourcesList) {
this.resourcesList = resourcesList;
}
public String getUserName() {
return userName;
}
public EnterpriseDTO setUserName(String userName) {
this.userName = userName;
return this;
}
public String getPhoneNumber() {
return phoneNumber;
}
public EnterpriseDTO setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
return this;
}
public String getPassword() {
return password;
}
public EnterpriseDTO setPassword(String password) {
this.password = password;
return this;
}
public Integer getPasswordType() {
return passwordType;
}
public EnterpriseDTO setPasswordType(Integer passwordType) {
this.passwordType = passwordType;
return this;
}
public String getConfirmPassword() {
return confirmPassword;
}
public EnterpriseDTO setConfirmPassword(String confirmPassword) {
this.confirmPassword = confirmPassword;
return this;
}
public String getPhoneAreaCode() {
return phoneAreaCode;
}
public EnterpriseDTO setPhoneAreaCode(String phoneAreaCode) {
this.phoneAreaCode = phoneAreaCode;
return this;
}
}
......@@ -4,12 +4,13 @@ import java.io.Serializable;
import java.math.BigDecimal;
import java.util.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.CollectionUtil;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
/**
* @ClassName: MarketServiceDTO

* @Description: 
 基础服务订购
......@@ -120,7 +121,7 @@ public class MarketServiceDTO implements Serializable{
}
public List<Map<String, Object>> getSkuMapList() {
Map<String, List<SkuDTO>> skuMap = CollectionUtil.group(skuList, "versionCode") ;
Map<String, List<SkuDTO>> skuMap = group(skuList, "versionCode") ;
List<Map<String, Object>> result = new ArrayList<>(skuMap.size());
for(Map.Entry<String, List<SkuDTO>> entry : skuMap.entrySet()) {
Map<String, Object> tempResult = new HashMap<>(16);
......@@ -211,4 +212,32 @@ public class MarketServiceDTO implements Serializable{
JSONObject json = (JSONObject) JSON.parse(discountDetail);
return (String) json.get("200");
}
public static <K, V> Map<K, List<V>> group(List<V> list, String field) {
Map<K, List<V>> map = new HashMap();
if (list != null && !list.isEmpty()) {
Object v;
Object sublist;
for(Iterator var3 = list.iterator(); var3.hasNext(); ((List)sublist).add(v)) {
v = var3.next();
Object p = null;
try {
p = PropertyUtils.getProperty(v, field);
} catch (Exception var7) {
throw new RuntimeException(var7.getMessage(), var7);
}
sublist = (List)map.get(p);
if (sublist == null) {
sublist = new ArrayList();
map.put(p, sublist);
}
}
return map;
} else {
return map;
}
}
}
package com.gic.enterprise.qo;
import java.io.Serializable;
/**
* 分页数据
* @ClassName: PageQO

* @Description: 

* @author guojuxing

* @date 2019/8/13 11:29 AM

*/
public class PageQO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 页码
*/
private Integer currentPage = 1;
/**
* 分页大小
*/
private Integer pageSize = 20;
public Integer getCurrentPage() {
if (currentPage == null) {
currentPage = 1;
}
return currentPage;
}
public void setCurrentPage(Integer currentPage) {
this.currentPage = currentPage;
}
public Integer getPageSize() {
if (pageSize == null) {
pageSize = 20;
}
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}
package com.gic.enterprise.service;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.enterprise.dto.BillingRechargeDTO;
import java.util.HashMap;
import java.util.Map;
/**
* 充值
* @ClassName: BillingRechargeApiService
......@@ -22,7 +24,7 @@ public interface BillingRechargeApiService {
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>
* @throws
*/
ServiceResponse<JSONObject> saveAndSelectPaymentMethod(BillingRechargeDTO billingRechargeDTO);
ServiceResponse<Map<String, Object>> saveAndSelectPaymentMethod(BillingRechargeDTO billingRechargeDTO);
/**
* 确认支付
......
package com.gic.enterprise.service;
import java.util.List;
import java.util.Map;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserDTO;
import com.gic.enterprise.dto.EnterpriseDTO;
import com.gic.enterprise.dto.EnterpriseLicenseDTO;
import com.gic.enterprise.dto.EnterpriseListDTO;
import com.gic.enterprise.dto.EnterpriseResourceRelDTO;
import com.gic.enterprise.dto.market.MarketServiceDTO;
import com.gic.enterprise.dto.market.OrderBuyLicenseDTO;
import com.gic.enterprise.dto.market.OrderGicDTO;
import com.gic.enterprise.qo.BuyForGicQO;
import com.gic.enterprise.qo.EnterpriseQO;
import com.gic.enterprise.qo.OrderServiceQO;
import java.util.List;
import java.util.Map;
/**
* 商户相关操作
* @ClassName: EnterpriseApiService

......@@ -32,10 +30,10 @@ public interface EnterpriseApiService {
* @Description:

 * @author guojuxing
* @param enterpriseDTO
* @param userDTO

* @param
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>


 */
ServiceResponse<Integer> saveEnterprise(EnterpriseDTO enterpriseDTO, UserDTO userDTO);
ServiceResponse<Integer> saveEnterprise(EnterpriseDTO enterpriseDTO);
/**
......
package com.gic.enterprise.utils;
import com.gic.commons.util.MD5Utils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import java.beans.PropertyDescriptor;
import java.util.Map;
import java.util.TreeMap;
/**
*
* @Description:
* @author zhiwj
* @date 2019/8/30 17:42
*/
public class SignUtils {
public static String getSign(Object source) {
final BeanWrapper src = new BeanWrapperImpl(source);
PropertyDescriptor[] pds = src.getPropertyDescriptors();
TreeMap<String, Object> propertys = new TreeMap<>();
for (PropertyDescriptor pd : pds) {
String name = pd.getName();
Object propertyValue = src.getPropertyValue(name);
if (propertyValue != null && !"sign".equals(name) && !"class".equals(name) && !"payType".equals(name)) {
propertys.put(name, propertyValue);
}
}
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, Object> entry : propertys.entrySet()) {
sb.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
}
if (sb.length() > 0) {
sb.deleteCharAt(sb.length() - 1);
}
return MD5Utils.ToMD5(sb.toString());
}
public static boolean validSign(Object source, String sign) {
return StringUtils.equals(SignUtils.getSign(source), sign);
}
}
package com.gic.enterprise.service.outer.impl;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.alibaba.fastjson.JSON;
import com.gic.commons.util.EntityUtil;
......@@ -108,8 +110,14 @@ public class AppletDecorationConfigApiServiceImpl implements AppletDecorationCon
result.setGpsDecisionCard(0);
result.setEnterpriseId(enterpriseId);
result.setAppId(appId);
//开卡认证关联
result.setOpenCardAuth(mainCardId.toString());
//开卡认证关联,全部的卡列表
//校验参数数值是否非法
ServiceResponse<List<AppletCardDTO>> appletCardResult = getMemberCardByAppId(appId, enterpriseId);
if (!appletCardResult.isSuccess()) {
return ServiceResponse.failure(appletCardResult.getCode(), appletCardResult.getMessage());
}
List<AppletCardDTO> appletCardList = appletCardResult.getResult();
result.setOpenCardAuth(appletCardList.stream().map(e -> e.getCardConfigId().toString()).collect(Collectors.joining(",")));
return ServiceResponse.success(result);
}
AppletDecorationConfigDTO dto = EntityUtil.changeEntityNew(AppletDecorationConfigDTO.class, record);
......@@ -214,20 +222,20 @@ public class AppletDecorationConfigApiServiceImpl implements AppletDecorationCon
return ServiceResponse.failure(appletCardResult.getCode(), appletCardResult.getMessage());
}
List<AppletCardDTO> appletCardList = appletCardResult.getResult();
Map<String, List<AppletCardDTO>> appletCardMap = new HashMap<>(16);
Map<String, List<AppletCardDTO>> appletCardMap = appletCardList
.stream()
.collect(Collectors.toMap(e -> e.getCardConfigId().toString(), e -> e.getSubList() ));
//子卡
List<String> appletSubCardList = new ArrayList<>();
for (AppletCardDTO cardDTO : appletCardList) {
appletCardMap.put(cardDTO.getCardConfigId().toString(), cardDTO.getSubList());
List<AppletCardDTO> subList = cardDTO.getSubList();
if (CollectionUtils.isNotEmpty(subList)) {
for (AppletCardDTO cardDTO1 : subList) {
if (cardDTO1.getCardConfigId().toString().equals(mainCardId.toString())) {
appletSubCardList.add(cardDTO.getCardConfigId().toString());
}
}
}
}
List<String> appletSubCardList = appletCardList
.stream()
.filter(e -> CollectionUtils.isNotEmpty(e.getSubList()))
.filter(e -> {
List<AppletCardDTO> subList = e.getSubList();
return subList.stream()
.anyMatch(son -> son.getCardConfigId().toString().equals(mainCardId.toString()));
})
.map(e -> e.getCardConfigId().toString())
.collect(Collectors.toList());
//需要校验的数值集合
Map<String, String> needValidMap = new HashMap<>(16);
......@@ -236,6 +244,7 @@ public class AppletDecorationConfigApiServiceImpl implements AppletDecorationCon
//数据资产
//总积分
String totalIntegral = appletDataAssetArea.getIntegral();
//线下订单
String order = appletDataAssetArea.getOrder();
needValidMap.put("数据资产-总积分", totalIntegral);
needValidMap.put("数据资产-卡券包", appletDataAssetArea.getCoupon());
......@@ -270,8 +279,12 @@ public class AppletDecorationConfigApiServiceImpl implements AppletDecorationCon
subListSet.add(temp.getCardConfigId().toString());
}
}
if (!totalIntegral.toString().equals(order) && !subListSet.contains(order)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "数据资产-线下订单只能选择总积分小程序主卡关联的平衡组卡及其子卡");
if (!totalIntegral.toString().equals(order)) {
boolean validOrder = Stream.of(order.split(","))
.anyMatch(e -> !subListSet.contains(e));
if (validOrder) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "数据资产-线下订单只能选择总积分小程序主卡关联的平衡组卡及其子卡");
}
}
}
......@@ -282,6 +295,8 @@ public class AppletDecorationConfigApiServiceImpl implements AppletDecorationCon
appletDataAssetArea.setMemberAchievement(mainCardId.toString());
//会员任务
appletDataAssetArea.setMemberTask(mainCardId.toString());
//关联卡组,全部的卡
dto.setOpenCardAuth(appletCardList.stream().map(e -> e.getCardConfigId().toString()).collect(Collectors.joining(",")));
Integer gpsDecisionCard = dto.getGpsDecisionCard();
if (gpsDecisionCard == null) {
......
......@@ -23,6 +23,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
/**
*
* @ClassName: BillingRechargeApiServiceImpl
......@@ -44,7 +46,7 @@ public class BillingRechargeApiServiceImpl implements BillingRechargeApiService
@Override
@Transactional
public ServiceResponse<JSONObject> saveAndSelectPaymentMethod(BillingRechargeDTO billingRechargeDTO) {
public ServiceResponse<Map<String, Object>> saveAndSelectPaymentMethod(BillingRechargeDTO billingRechargeDTO) {
String serialNumber = StringUtils.isNotBlank(billingRechargeDTO.getSerialNumber())?billingRechargeDTO.getSerialNumber(): CreateSerialNumberUtils.createSerialNumber();
ServiceResponse<BillingPayInfoDTO> serviceResponse = billingPayInfoApiService.savePrePayInfo(billingRechargeDTO.getEnterpriseId(), billingRechargeDTO.getTotalFee(), billingRechargeDTO.getPayType(), BuyTypeEnum.BALANCE_RECHARGE.getCode(), serialNumber);
if (!serviceResponse.isSuccess()) {
......
......@@ -86,7 +86,7 @@ public class EnterpriseApiServiceImpl implements EnterpriseApiService {
@Override
@Transactional(rollbackFor = Exception.class)
public ServiceResponse<Integer> saveEnterprise(EnterpriseDTO enterpriseDTO, UserDTO userDTO) {
public ServiceResponse<Integer> saveEnterprise(EnterpriseDTO enterpriseDTO) {
//valid param
ServiceResponse paramResult = ValidUtil.allCheckValidate(enterpriseDTO,
EnterpriseDTO.SaveEnterpriseValid.class);
......@@ -142,6 +142,7 @@ public class EnterpriseApiServiceImpl implements EnterpriseApiService {
//初始化计费中心账户
billingAccountService.createBillingAccount(enterpriseId);
UserDTO userDTO = EntityUtil.changeEntityNew(UserDTO.class, enterpriseDTO);
//新增超级管理员
userDTO.setEnterpriseId(enterpriseId);
//超级管理员
......
package com.gic.enterprise.web.controller;
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;
......@@ -27,6 +26,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
*
* @Description:
......@@ -54,7 +55,7 @@ public class BillingRechargeController {
billingRechargeDTO.setInitiator(BillingInitiatorTypeEnum.ENTERPRISE.getCode());
billingRechargeDTO.setInitiatorUser(userDetail.getUserId());
billingRechargeDTO.setInitiatorName(userDetail.getUserInfo().getUserName());
ServiceResponse<JSONObject> serviceResponse = billingRechargeApiService.saveAndSelectPaymentMethod(billingRechargeDTO);
ServiceResponse<Map<String, Object>> serviceResponse = billingRechargeApiService.saveAndSelectPaymentMethod(billingRechargeDTO);
if (serviceResponse.isSuccess()) {
LogUtils.createLog("预支付金额:" + billingRechargeQO.getTotalFee(), PayTypeEnum.getMessageByCode(billingRechargeQO.getPayType()));
}
......
......@@ -122,7 +122,13 @@ public class EnterpriseController {
//密码加密
userDTO.setPassword(UserPasswordUtil.getEncryptPassword(password));
//新增商户
ServiceResponse<Integer> result = enterpriseApiService.saveEnterprise(enterpriseDTO, userDTO);
enterpriseDTO.setUserName(userDTO.getUserName())
.setPassword(userDTO.getPassword())
.setConfirmPassword(userDTO.getConfirmPassword())
.setPasswordType(userDTO.getPasswordType())
.setPhoneAreaCode(userDTO.getPhoneAreaCode())
.setPhoneNumber(userDTO.getPhoneNumber());
ServiceResponse<Integer> result = enterpriseApiService.saveEnterprise(enterpriseDTO);
if (result.isSuccess() && UserConstants.CREATE_AUTO == userDTO.getPasswordType().intValue()) {
//发送短信,通知自动生成密码
if (StringUtils.isBlank(userDTO.getPhoneAreaCode())) {
......
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