| | |
| | | using CoreCms.Net.Utility.Extensions; |
| | | using CoreCms.Net.Utility.Helper; |
| | | using CoreCms.Net.Web.Admin.Infrastructure; |
| | | using Essensoft.Paylink.Alipay.Domain; |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Hosting; |
| | | using Microsoft.AspNetCore.Mvc; |
| | |
| | | { |
| | | var jm = new AdminUiCallBack(); |
| | | |
| | | var user = await _userServices.QueryByClauseAsync(p => p.mobile == entity.registeredUserMobile); |
| | | var user = await _userServices.QueryByClauseAsync(p => p.id == entity.userId); |
| | | if (user == null) |
| | | { |
| | | jm.msg = "提交的【已注册手机号】未查询到注册用户"; |
| | |
| | | var isDistribution = await _coreCmsDistributionServices.ExistsAsync(p => p.userId == user.id); |
| | | if (isDistribution) |
| | | { |
| | | jm.msg = "提交的【已注册手机号】已经是经销商了。"; |
| | | jm.msg = "提交的用户已经有经销商记录,请找到相关项进行审核"; |
| | | return jm; |
| | | } |
| | | var model = new CoreCmsDistribution(); |
| | | |
| | | model.userId = user.id; |
| | | model.mobile = entity.registeredUserMobile; |
| | | model.name = entity.name; |
| | | model.gradeId = entity.gradeId; |
| | | model.mobile = string.IsNullOrEmpty(entity.mobile) ? user.mobile : entity.mobile; |
| | | model.weixin = entity.weixin; |
| | | model.qq = entity.qq; |
| | | model.profession = entity.profession; |
| | | model.storeCoordinate = entity.storeCoordinate; |
| | | model.storeLogo = entity.storeBanner; |
| | | model.storeName= entity.storeName; |
| | | model.sales=entity.sales; |
| | | model.areaCode=entity.areaCode; |
| | | model.address=entity.address; |
| | | model.verifyStatus = entity.verifyStatus; |
| | | model.createTime = DateTime.Now; |
| | | model.isDelete = false; |
| | | if (model.verifyStatus == (int)GlobalEnumVars.DistributionVerifyStatus.VerifyYes) model.verifyTime = DateTime.Now; |
| | | try |
| | | { |
| | | _unitOfWork.BeginTran(); |
| | | if (model.verifyStatus == (int)GlobalEnumVars.DistributionVerifyStatus.VerifyYes) |
| | | { |
| | | model.verifyTime = DateTime.Now; |
| | | //老模型未通过审核,新模型未通过审核,那么为审核通过过程 |
| | | var allConfigs = await _coreCmsSettingServices.GetConfigDictionaries(); |
| | | var kc = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.DictionaryUserGroupKey); |
| | | |
| | | var id = await _coreCmsDistributionServices.InsertAsync(model); |
| | | var group = await _userGradeServices.GetUserGradeByValueKey(kc); |
| | | if (group != null) |
| | | { |
| | | |
| | | jm.code = id > 0 ? 0 : 1; |
| | | jm.msg = id > 0 ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure; |
| | | //关联经销商用户等级 |
| | | if (user != null) |
| | | { |
| | | user.grade = group.id; |
| | | user.updataTime = DateTime.Now; |
| | | await _userServices.UpdateAsync(user); |
| | | |
| | | } |
| | | } |
| | | //处理店铺 |
| | | if (entity.profession == "文具店") |
| | | { |
| | | |
| | | //新建店铺名称 |
| | | |
| | | var store = await _coreCmsStoreServices.QueryByClauseAsync(x => x.userID == model.userId); |
| | | if (store != null) |
| | | { |
| | | //存在店铺 |
| | | store.coordinate = entity.storeCoordinate; |
| | | store.storeName = entity.storeName; |
| | | //用logo代替门头照片 |
| | | store.logoImage = model.storeLogo; |
| | | store.en = true; |
| | | store.updateTime = DateTime.Now; |
| | | await _coreCmsStoreServices.UpdateAsync(store); |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | | var areaCode = model.areaCode.Split(',').OrderByDescending(x => x).FirstOrDefault(); |
| | | var db = _unitOfWork.GetDbClient(); |
| | | string[] lat = []; |
| | | if (!string.IsNullOrEmpty(model.storeCoordinate)) |
| | | lat = model.storeCoordinate.Split(","); |
| | | //新建地铺 |
| | | store = new CoreCmsStore |
| | | { |
| | | userID = model.userId, |
| | | address = model.address, |
| | | areaId = areaCode.ToInt32OrDefault(510000), |
| | | storeName = model.storeName, |
| | | coordinate = model.storeCoordinate, |
| | | createTime = DateTime.Now, |
| | | mobile = model.mobile, |
| | | linkMan = user.nickName, |
| | | |
| | | |
| | | |
| | | }; |
| | | if (lat.Length == 2) |
| | | { |
| | | store.latitude = lat[0]; |
| | | store.longitude = lat[1]; |
| | | } |
| | | var storeid = await _unitOfWork.GetDbClient().Insertable(store).ExecuteReturnIdentityAsync(); |
| | | |
| | | //将自己设置为店员 |
| | | CoreCmsClerk clerk = new CoreCmsClerk() |
| | | { |
| | | createTime = DateTime.Now, |
| | | storeId = storeid, |
| | | userId = entity.userId, |
| | | |
| | | }; |
| | | await _coreCmsClerkServices.InsertAsync(clerk); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | await _coreCmsDistributionServices.InsertAsync(model); |
| | | |
| | | _unitOfWork.CommitTran(); |
| | | } |
| | | catch (Exception) |
| | | { |
| | | _unitOfWork.RollbackTran(); |
| | | throw; |
| | | } |
| | | |
| | | |
| | | jm.code = 1; |
| | | jm.msg = GlobalConstVars.CreateSuccess ; |
| | | return jm; |
| | | } |
| | | #endregion |