|
@@ -5,28 +5,29 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.gree.mall.contest.bean.admin.AdminUserCom;
|
|
|
-import com.gree.mall.contest.bean.merchant.WebsitApplyAdd;
|
|
|
-import com.gree.mall.contest.bean.merchant.WebsitApplyDetail;
|
|
|
-import com.gree.mall.contest.bean.merchant.WebsitApplyVO;
|
|
|
+import com.gree.mall.contest.bean.merchant.*;
|
|
|
import com.gree.mall.contest.bean.zfire.ZfireParamBean;
|
|
|
import com.gree.mall.contest.commonmapper.CommonMapper;
|
|
|
+import com.gree.mall.contest.constant.Constant;
|
|
|
+import com.gree.mall.contest.enums.admin.RoleTypeEnum;
|
|
|
+import com.gree.mall.contest.enums.admin.UpdateLogRemarkEnum;
|
|
|
+import com.gree.mall.contest.enums.base.BaseEnum;
|
|
|
+import com.gree.mall.contest.enums.merchant.MerchantStatusEnum;
|
|
|
import com.gree.mall.contest.exception.RemoteServiceException;
|
|
|
import com.gree.mall.contest.logic.SMSLogic;
|
|
|
import com.gree.mall.contest.logic.common.CommonLogic;
|
|
|
-import com.gree.mall.contest.plus.entity.GoodsCategory;
|
|
|
-import com.gree.mall.contest.plus.entity.WebsitApply;
|
|
|
-import com.gree.mall.contest.plus.entity.WebsitApplyArea;
|
|
|
-import com.gree.mall.contest.plus.entity.WebsitApplyLog;
|
|
|
-import com.gree.mall.contest.plus.service.GoodsCategoryService;
|
|
|
-import com.gree.mall.contest.plus.service.WebsitApplyAreaService;
|
|
|
-import com.gree.mall.contest.plus.service.WebsitApplyLogService;
|
|
|
-import com.gree.mall.contest.plus.service.WebsitApplyService;
|
|
|
+import com.gree.mall.contest.plus.entity.*;
|
|
|
+import com.gree.mall.contest.plus.service.*;
|
|
|
+import com.gree.mall.contest.utils.CommonUtils;
|
|
|
+import com.gree.mall.contest.utils.MD5Utils;
|
|
|
import com.gree.mall.contest.utils.zfire.FieldUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -41,6 +42,9 @@ public class MerchantLogic {
|
|
|
private final WebsitApplyAreaService websitApplyAreaService;
|
|
|
private final GoodsCategoryService goodsCategoryService;
|
|
|
private final WebsitApplyLogService websitApplyLogService;
|
|
|
+ private final MerchantService merchantService;
|
|
|
+ private final AdminRoleService adminRoleService;
|
|
|
+ private final AdminUserService adminUserService;
|
|
|
|
|
|
public Boolean register(String mobile, String code) {
|
|
|
smsLogic.checkSmsCode(mobile, code, "BIND");
|
|
@@ -121,4 +125,160 @@ public class MerchantLogic {
|
|
|
websitApplyLog.setRemark(remark);
|
|
|
websitApplyLog.insert();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商家列表
|
|
|
+ *
|
|
|
+ * @param zfireParamBean
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IPage<MerchantVO> list(ZfireParamBean zfireParamBean) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+ zfireParamBean = FieldUtils.supplyParam(zfireParamBean, MerchantVO.class);
|
|
|
+ IPage<MerchantVO> page = commonMapper.MerchantPage(zfireParamBean.page(), zfireParamBean, adminUser.getServiceProviderId());
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ public IPage<MerchantRegionVO> list2(ZfireParamBean zfireParamBean) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+ FieldUtils.supplyParam(zfireParamBean, MerchantRegionVO.class);
|
|
|
+
|
|
|
+ List<String> types = new ArrayList<>();
|
|
|
+ types.add("C");
|
|
|
+ types.add("E");
|
|
|
+
|
|
|
+ String providerId = types.contains(adminUser.getAdminWebsit().getType()) ? null : adminUser.getServiceProviderId();
|
|
|
+ IPage<MerchantRegionVO> page = commonMapper.listMerchantRegion(zfireParamBean.page(),
|
|
|
+ zfireParamBean, providerId);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商家保存
|
|
|
+ * @param merchantAddBean
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public MerchantBean add(MerchantAddBean merchantAddBean) {
|
|
|
+ if(StringUtils.isBlank(merchantAddBean.getNumber())){
|
|
|
+ throw new RemoteServiceException("商家编号必填");
|
|
|
+ }
|
|
|
+
|
|
|
+ String id = merchantAddBean.getNumber().toUpperCase();
|
|
|
+
|
|
|
+ merchantAddBean.setId(id);
|
|
|
+
|
|
|
+ //判断是否存在
|
|
|
+ Merchant old = merchantService.getById(merchantAddBean.getNumber());
|
|
|
+ if(old != null){
|
|
|
+ throw new RemoteServiceException("编号【"+old.getId()+"】已存在");
|
|
|
+ }
|
|
|
+ merchantAddBean.setId(merchantAddBean.getNumber());
|
|
|
+ merchantAddBean.insert();
|
|
|
+ //角色
|
|
|
+ AdminRole adminRole = adminRoleService.getById(Constant.SERVICE_PROVIDER.ROLE_ID);
|
|
|
+ if(adminRole == null){
|
|
|
+ throw new RemoteServiceException("请先配置服务商角色");
|
|
|
+ }
|
|
|
+ //判断负责人手机号是否存在
|
|
|
+// Integer count = adminUserService.lambdaQuery().eq(AdminUser::getLinkPhone, serviceProvider.getChargeMobile()).count();
|
|
|
+// if(count > 0){
|
|
|
+// throw new RemoteServiceException("负责人手机号已存在,请更换");
|
|
|
+// }
|
|
|
+ //生成部门
|
|
|
+ AdminWebsit adminWebsit = new AdminWebsit();
|
|
|
+ adminWebsit.setWebsitId(merchantAddBean.getId());
|
|
|
+ adminWebsit.setName(merchantAddBean.getName());
|
|
|
+ adminWebsit.setParentId(Constant.SERVICE_PROVIDER.PARENT_WEBSIT_ID);
|
|
|
+ adminWebsit.setType(RoleTypeEnum.B.getCode());
|
|
|
+ adminWebsit.insert();
|
|
|
+ //生成账号
|
|
|
+ AdminUser adminUser = new AdminUser();
|
|
|
+ adminUser.setUserName(merchantAddBean.getChargeMobile());
|
|
|
+ adminUser.setNickName(merchantAddBean.getName());
|
|
|
+ adminUser.setRoleId(adminRole.getAdminRoleId());
|
|
|
+ adminUser.setRoleName(adminRole.getName());
|
|
|
+ adminUser.setType(adminWebsit.getType());
|
|
|
+ adminUser.setUserName(merchantAddBean.getId());
|
|
|
+ adminUser.setPassword(MD5Utils.md5("123456"));
|
|
|
+ adminUser.setAdminWebsitId(adminWebsit.getWebsitId());
|
|
|
+ adminUser.setLinkName(merchantAddBean.getChargeName());
|
|
|
+ adminUser.setLinkPhone(merchantAddBean.getChargeMobile());
|
|
|
+ adminUser.setAddress(merchantAddBean.getAddress());
|
|
|
+ adminUser.setServiceProviderId(adminWebsit.getWebsitId());
|
|
|
+ adminUser.insert();
|
|
|
+
|
|
|
+ return merchantDetail(merchantAddBean.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商家详情
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public MerchantBean merchantDetail(String id){
|
|
|
+ Merchant merchant = merchantService.getById(id);
|
|
|
+ MerchantBean serviceProviderBean = BeanUtil.copyProperties(merchant, MerchantBean.class);
|
|
|
+
|
|
|
+ return serviceProviderBean;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void update(MerchantAddBean serviceProvider) {
|
|
|
+ //旧服务商
|
|
|
+ Merchant old = merchantService.getById(serviceProvider.getId());
|
|
|
+ //判断是否从有效变为无效
|
|
|
+ if(old.getStatus() == 1 && serviceProvider.getStatus() == 0){
|
|
|
+// Integer count1 = orderBaseService.lambdaQuery()
|
|
|
+// .notIn(OrderBase::getOrderStatus, OrderBaseStatusEnum.isOver())
|
|
|
+// .eq(OrderBase::getWebsitId, serviceProvider.getId()).count();
|
|
|
+// if(count1 > 0){
|
|
|
+// throw new RemoteServiceException("服务商存在未完成的工单,不可将状态变更无效/终止,请改派之后再操作");
|
|
|
+// }
|
|
|
+ }
|
|
|
+ //编号不能改
|
|
|
+ serviceProvider.setNumber(null);
|
|
|
+ serviceProvider.updateById();
|
|
|
+
|
|
|
+ //更新账号信息
|
|
|
+ AdminUser adminUser = adminUserService.lambdaQuery()
|
|
|
+ .eq(AdminUser::getServiceProviderId, serviceProvider.getId())
|
|
|
+ .eq(AdminUser::getType, RoleTypeEnum.B.getCode()).one();
|
|
|
+ if(adminUser != null) {
|
|
|
+ adminUser.setLinkName(serviceProvider.getChargeName());
|
|
|
+ adminUser.setLinkPhone(serviceProvider.getChargeMobile());
|
|
|
+ adminUser.setAddress(serviceProvider.getAddress());
|
|
|
+ adminUser.setNickName(serviceProvider.getName());
|
|
|
+ adminUser.updateById();
|
|
|
+ }
|
|
|
+
|
|
|
+ //操作日志
|
|
|
+ MerchantStatusEnum oldStatusEnum = BaseEnum.intKeyToEnum(MerchantStatusEnum.class, old.getStatus());
|
|
|
+ MerchantStatusEnum newStatusEnum = BaseEnum.intKeyToEnum(MerchantStatusEnum.class, serviceProvider.getStatus());
|
|
|
+
|
|
|
+ StringBuffer sbLog = new StringBuffer();
|
|
|
+ sbLog.append(CommonUtils.supplyLog("状态",oldStatusEnum.getRemark(),newStatusEnum.getRemark()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("服务商名称",old.getName(),serviceProvider.getName()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("负责人",old.getChargeName(),serviceProvider.getChargeName()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("负责人电话",old.getChargeMobile(),serviceProvider.getChargeMobile()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("办公电话",old.getOfficeMobile(),serviceProvider.getOfficeMobile()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("税号",old.getTaxNo(),serviceProvider.getTaxNo()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("是否独立法人",old.getIsLegal(),serviceProvider.getIsLegal()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("法人代表",old.getLegalName(),serviceProvider.getLegalName()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("法人身份证号",old.getLegalIdcard(),serviceProvider.getLegalIdcard()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("法人手机号",old.getLegalMobile(),serviceProvider.getLegalMobile()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("详细地址",old.getAddress(),serviceProvider.getAddress()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("营业时间开始",old.getStartTime(),serviceProvider.getStartTime()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("营业时间结束",old.getEndTime(),serviceProvider.getEndTime()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("银行账号",old.getBankAccount(),serviceProvider.getBankAccount()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("开户行号",old.getBankNo(),serviceProvider.getBankNo()));
|
|
|
+ sbLog.append(CommonUtils.supplyLog("开户银行",old.getBank(),serviceProvider.getBank()));
|
|
|
+ if(StringUtils.isNotBlank(sbLog.toString())) {
|
|
|
+ commonLogic.addUpdateLog(serviceProvider.getId(), sbLog.toString(), UpdateLogRemarkEnum.A);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除商家
|
|
|
+ */
|
|
|
+ public void delete(String id){
|
|
|
+ merchantService.removeById(id);
|
|
|
+ }
|
|
|
}
|