|
@@ -24,6 +24,7 @@ import com.zhongzheng.common.utils.*;
|
|
|
import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
import com.zhongzheng.modules.activity.domain.ActivityGoodsPrice;
|
|
|
import com.zhongzheng.modules.activity.service.IActivityGoodsPriceService;
|
|
|
+import com.zhongzheng.modules.alioss.service.OssService;
|
|
|
import com.zhongzheng.modules.bank.domain.*;
|
|
|
import com.zhongzheng.modules.bank.mapper.QuestionMapper;
|
|
|
import com.zhongzheng.modules.bank.service.*;
|
|
@@ -71,9 +72,11 @@ import com.zhongzheng.modules.polyv.service.IPolyvVideoService;
|
|
|
import com.zhongzheng.modules.system.bo.GoodsCopyEnum;
|
|
|
import com.zhongzheng.modules.system.domain.SysConfig;
|
|
|
import com.zhongzheng.modules.system.domain.SysGoodsCopyRecord;
|
|
|
+import com.zhongzheng.modules.system.domain.SysOldOrg;
|
|
|
import com.zhongzheng.modules.system.domain.SysTenant;
|
|
|
import com.zhongzheng.modules.system.service.ISysConfigService;
|
|
|
import com.zhongzheng.modules.system.service.ISysGoodsCopyRecordService;
|
|
|
+import com.zhongzheng.modules.system.service.ISysOldOrgService;
|
|
|
import com.zhongzheng.modules.system.service.ISysTenantService;
|
|
|
import com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo;
|
|
|
import com.zhongzheng.modules.user.bo.UserPhoneBo;
|
|
@@ -93,9 +96,13 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.net.URL;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
@@ -276,11 +283,16 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
@Autowired
|
|
|
private ISysTenantService iSysTenantService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysOldOrgService iSysOldOrgService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ISysGoodsCopyRecordService iGoodsCopyRecordService;
|
|
|
|
|
|
@Autowired
|
|
|
private IActivityGoodsPriceService iActivityGoodsPriceService;
|
|
|
+ @Autowired
|
|
|
+ private OssService ossService;
|
|
|
|
|
|
|
|
|
@Value("${oldStudySys.educationalInspector}")
|
|
@@ -5389,6 +5401,84 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String createUserAccount(UserAccountBo bo) {
|
|
|
+ if (ObjectUtils.isNull(bo.getIdCard())){
|
|
|
+ throw new CustomException("身份证不能为空");
|
|
|
+ }
|
|
|
+ SysOldOrg oldOrg = iSysOldOrgService.getOne(new LambdaQueryWrapper<SysOldOrg>()
|
|
|
+ .eq(SysOldOrg::getOrgId, bo.getOrgId())
|
|
|
+ .last("limit 1"));
|
|
|
+ Long tenantId = oldOrg.getTenantId();
|
|
|
+ User user = iUserService.getByCardTenant(bo.getIdCard(),tenantId.toString());
|
|
|
+ if (ObjectUtils.isNull(user)){
|
|
|
+ //用户不存在
|
|
|
+ User u = BeanUtil.toBean(bo, User.class);
|
|
|
+ //雪花算法产生账号ID
|
|
|
+ SnowflakeIdUtils idWorker = new SnowflakeIdUtils(3, 1);
|
|
|
+ u.setUserAccount(String.valueOf(idWorker.nextId()));
|
|
|
+ u.setCreateTime(DateUtils.getNowTime());
|
|
|
+ u.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ u.setStatus(1);
|
|
|
+ //设置默认密码
|
|
|
+ if (ObjectUtils.isNotNull(bo.getPassword())){
|
|
|
+ u.setPasswordAes(EncryptHandler.encrypt(bo.getPassword()));
|
|
|
+ u.setPassword(SecurityUtils.encryptPassword(bo.getPassword()));
|
|
|
+ }else {
|
|
|
+ String substring = bo.getIdCard().substring(bo.getIdCard().length() - 6);
|
|
|
+ u.setPasswordAes(EncryptHandler.encrypt(substring));
|
|
|
+ u.setPassword(SecurityUtils.encryptPassword(substring));
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理身份证照片
|
|
|
+ if (ObjectUtils.isNotNull(bo.getIdCardImg1()) && ObjectUtils.isNotNull(bo.getIdCardImg2())){
|
|
|
+ try {
|
|
|
+ URL url = new URL(bo.getIdCardImg1());
|
|
|
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
+ int responseCode = connection.getResponseCode();
|
|
|
+ if (responseCode == HttpURLConnection.HTTP_OK) {
|
|
|
+ InputStream inputStream = connection.getInputStream();
|
|
|
+ String s = ossService.uploadInputStream(inputStream, 5);
|
|
|
+ u.setIdCardImg1(s);
|
|
|
+ }
|
|
|
+ URL url2 = new URL(bo.getIdCardImg2());
|
|
|
+ HttpURLConnection connection2 = (HttpURLConnection) url2.openConnection();
|
|
|
+ int responseCode2 = connection2.getResponseCode();
|
|
|
+ if (responseCode2 == HttpURLConnection.HTTP_OK) {
|
|
|
+ InputStream inputStream = connection2.getInputStream();
|
|
|
+ String s = ossService.uploadInputStream(inputStream, 5);
|
|
|
+ u.setIdCardImg2(s);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ u.setTenantId(tenantId);
|
|
|
+ iUserService.save(u);
|
|
|
+ user = u;
|
|
|
+ }
|
|
|
+
|
|
|
+ //缓存用户信息key
|
|
|
+ String key = String.format("KQTZ%s", user.getUserId());
|
|
|
+ SysTenant sysTenant = iSysTenantService.getById(tenantId);
|
|
|
+ //跳转路径
|
|
|
+ String url = "";
|
|
|
+ if (ObjectUtils.isNotNull(bo.getPostSign()) && bo.getPostSign() == 2){
|
|
|
+ url = String.format("%s%s/pages/learn/index?skipPort=%s", URL_PREFIX, sysTenant.getHostH5(), key);
|
|
|
+ }else {
|
|
|
+ url = String.format("%s%s/person-center/my-course?skipPort=%s", URL_PREFIX, sysTenant.getHostPc(), key);
|
|
|
+ }
|
|
|
+ UserPhoneBo phoneBo = new UserPhoneBo();
|
|
|
+ phoneBo.setTelphone(EncryptHandler.decryptTwo(user.getTelphone()));
|
|
|
+ phoneBo.setTenantId(tenantId);
|
|
|
+ phoneBo.setIdNum(EncryptHandler.decryptTwo(user.getIdCard()));
|
|
|
+
|
|
|
+ //缓存用户信息
|
|
|
+ redisCache.setCacheObjectTenant(tenantId + ":" + key, JSONObject.toJSONString(phoneBo), 12, TimeUnit.HOURS);
|
|
|
+ return url;
|
|
|
+ }
|
|
|
+
|
|
|
private void updateHandoutsId(Long goodsId, Long tenantId, Long handoutsId) {
|
|
|
baseMapper.updateHandoutsId(goodsId, tenantId, handoutsId);
|
|
|
}
|