|
@@ -0,0 +1,109 @@
|
|
|
+package com.caimei365.user.service.impl;
|
|
|
+
|
|
|
+import com.caimei365.user.components.CommonService;
|
|
|
+import com.caimei365.user.mapper.OperationMapper;
|
|
|
+import com.caimei365.user.model.ResponseJson;
|
|
|
+import com.caimei365.user.model.dto.OperationDto;
|
|
|
+import com.caimei365.user.model.po.OperationPo;
|
|
|
+import com.caimei365.user.service.OperationService;
|
|
|
+import com.caimei365.user.utils.AliyunSmsUtil;
|
|
|
+import com.caimei365.user.utils.CodeUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Description
|
|
|
+ *
|
|
|
+ * @author : Charles
|
|
|
+ * @date : 2021/4/19
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class OperationServiceImpl implements OperationService {
|
|
|
+ @Resource
|
|
|
+ private CommonService commonService;
|
|
|
+ @Resource
|
|
|
+ private OperationMapper operationMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加运营人员
|
|
|
+ *
|
|
|
+ * @param operationDto {
|
|
|
+ * mobile 手机号
|
|
|
+ * linkName 姓名
|
|
|
+ * userId 用户Id(userID)
|
|
|
+ * clubId 机构Id
|
|
|
+ * configFlag 确认标志
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson addOperation(OperationDto operationDto) {
|
|
|
+ // 查询使用该手机号的运营人员或用户
|
|
|
+// String checkRust = commonService.operationBindCheck(operationDto.getMobile(), null);
|
|
|
+// if (checkRust != null) {
|
|
|
+// return ResponseJson.error(checkRust, null);
|
|
|
+// }
|
|
|
+// OperationPo operation = new OperationPo();
|
|
|
+// Date date = new Date();
|
|
|
+// // 保存生成邀请码
|
|
|
+// if (operationDto.getConfigFlag() == 2) {
|
|
|
+// //生成随机码6位
|
|
|
+// String invitationCode = generateInvitationCode();
|
|
|
+// operation.setInvitationCode(invitationCode);
|
|
|
+// operation.setInvitationCodeTime(date);
|
|
|
+// operation.setStatus(1);
|
|
|
+// //发送短信
|
|
|
+// String name = null;
|
|
|
+// if (operationDto.getClubId() != null) {
|
|
|
+// name = operationMapper.findClubNameById(operationDto.getClubId());
|
|
|
+// } else {
|
|
|
+// name = operationMapper.findShopNameById(operationDto.getShopId());
|
|
|
+// }
|
|
|
+// String mobile = operationDto.getMobile();
|
|
|
+// boolean sendFlag = false;
|
|
|
+// if (StringUtils.isNotEmpty(mobile)) {
|
|
|
+// sendFlag = AliyunSmsUtil.sendSms(mobile, 11, "{name:"+ name +",code:" + invitationCode + "}");
|
|
|
+// log.info("欢迎成为"+ name +"的运营人员,您的邀请码为:" + invitationCode);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (operationDto.getShopId() == null) {
|
|
|
+// operation.setUserType(1);
|
|
|
+// } else {
|
|
|
+// operation.setUserType(2);
|
|
|
+// }
|
|
|
+// operation.setAddTime(date);
|
|
|
+// operation.setUpdateTime(date);
|
|
|
+// operation.setDelFlag(0);
|
|
|
+// operation.setOrganizeId(0);
|
|
|
+// int flag = 0;
|
|
|
+// if (operation.getId() == null) {
|
|
|
+// operation.setAccount(operationDto.getMobile() + CodeUtil.generateAccount(2));
|
|
|
+// operation.setStatus(1);
|
|
|
+// flag = operationMapper.insertOperation(operation);
|
|
|
+// } else {
|
|
|
+// flag = operationMapper.updateOperation(operation);
|
|
|
+// }
|
|
|
+// return flag > 0 ? ResponseJson.success() : ResponseJson.error();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成六位随机码
|
|
|
+ */
|
|
|
+ private String generateInvitationCode(){
|
|
|
+ // 生成六位随机码
|
|
|
+ String invitationCode = CodeUtil.generateCodeInt(6);
|
|
|
+ // 判断生成随机码是否和数据库有重复
|
|
|
+ int count = operationMapper.countByInvitationCode(invitationCode);
|
|
|
+ // 存在邀请码重新获取
|
|
|
+ if (count > 0) {
|
|
|
+ generateInvitationCode();
|
|
|
+ }
|
|
|
+ return invitationCode;
|
|
|
+ }
|
|
|
+}
|