From 445d14becca6b5251814934343d7a6394ada6009 Mon Sep 17 00:00:00 2001
From: 小飞侠 <8277136+liaoxujun@user.noreply.gitee.com>
Date: 星期五, 17 十月 2025 16:55:19 +0800
Subject: [PATCH] no message
---
CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs | 203 +++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 189 insertions(+), 14 deletions(-)
diff --git a/CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs b/CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs
index d9d042f..1e7836d 100644
--- a/CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs
+++ b/CoreCms.Net.Web.Admin/Controllers/Distribution/CoreCmsDistributionController.cs
@@ -27,10 +27,12 @@
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;
using Microsoft.CodeAnalysis.Operations;
+using NPOI.SS.Formula.Functions;
using SqlSugar;
using ZstdSharp.Unsafe;
@@ -316,7 +318,7 @@
{
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 = "鎻愪氦鐨勩�愬凡娉ㄥ唽鎵嬫満鍙枫�戞湭鏌ヨ鍒版敞鍐岀敤鎴�";
@@ -326,27 +328,130 @@
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.userId = user.id;
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 group = await _userGradeServices.GetUserGradeByValueKey(kc);
+ if (group != null)
+ {
- var id = await _coreCmsDistributionServices.InsertAsync(model);
+ //鍏宠仈缁忛攢鍟嗙敤鎴风瓑绾�
+ if (user != null)
+ {
+ user.grade = group.id;
+ user.updataTime = DateTime.Now;
+ await _userServices.UpdateAsync(user);
- jm.code = id > 0 ? 0 : 1;
- jm.msg = id > 0 ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
+ }
+ }
+ //澶勭悊搴楅摵
+ if (entity.profession == "鏂囧叿搴�")
+ {
+
+ //鏂板缓搴楅摵鍚嶇О
+
+ var store = await _coreCmsStoreServices.QueryByClauseAsync(x => x.userID == model.userId);
+ if (store != null)
+ {
+ //瀛樺湪搴楅摵
+ store.coordinate = entity.storeCoordinate;
+ store.storeName = entity.storeName;
+ //鐢╨ogo浠f浛闂ㄥご鐓х墖
+ 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
@@ -635,11 +740,76 @@
jm.msg = GlobalConstVars.DataisNo;
return jm;
}
+ try
+ {
+ _unitOfWork.BeginTran();
+
+ //濡傛灉鏄彇娑堝鏍�
- var bl = await _coreCmsDistributionServices.DeleteByIdAsync(entity.id);
- jm.code = bl ? 0 : 1;
- jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
- return jm;
+ var allConfigs = await _coreCmsSettingServices.GetConfigDictionaries();
+ var kc = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.DictionaryUserGroupKey);
+ var group = await _userGradeServices.GetUserGradeByValueKey(kc);
+ var defgroup = await _userGradeServices.GetDefaultUserGrade();
+ if (defgroup != null)
+ {
+ var olduser = await _userServices.QueryByIdAsync(model.userId);
+ if (olduser != null)
+ {//澶勭悊鐢ㄦ埛绛夌骇
+ if (olduser.grade == group.id)
+ {
+ if (defgroup != null)
+ {
+ olduser.grade = defgroup.id;
+ }
+ else
+ {
+
+ olduser.grade = 0;
+ }
+
+ olduser.updataTime = DateTime.Now;
+ await _userServices.UpdateAsync(olduser);
+
+ }
+ }
+ var store = await _coreCmsStoreServices.QueryByClauseAsync(x => x.userID == model.userId);
+ //澶勭悊搴楅摵 鍙栨秷宸叉湁搴楅摵鐨勪娇鑳�
+ if(store != null )
+
+ {
+
+
+ // var clerk= await _unitOfWork.GetDbClient().Queryable<CoreCmsClerk>().Where(x => x.storeId == store.id).ToListAsync();
+ //鍒犻櫎搴楅摵鍛樺伐
+ await _unitOfWork.GetDbClient().Deleteable<CoreCmsClerk>().Where(x=>x.storeId==store.id).ExecuteCommandAsync();
+ //鍒犻櫎搴楅摵
+ await _coreCmsStoreServices.DeleteByIdAsync(store.id);
+
+
+
+ }
+
+
+ }
+ var bl = await _coreCmsDistributionServices.DeleteByIdAsync(entity.id);
+
+ _unitOfWork.CommitTran();
+ jm.code = bl ? 0 : 1;
+ jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
+
+ return jm;
+
+ }
+ catch (Exception)
+ {
+
+ _unitOfWork.RollbackTran();
+ jm.code = 1;
+ jm.msg = GlobalConstVars.DeleteFailure;
+
+ return jm;
+ }
+
}
@@ -714,5 +884,10 @@
}
#endregion
+
+
+
+
+
}
}
\ No newline at end of file
--
Gitblit v1.9.1