提交 | 用户 | age
|
a6a76f
|
1 |
package com.yc.sdk.miniapp.service; |
F |
2 |
|
|
3 |
import java.text.SimpleDateFormat; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.Date; |
|
6 |
import java.util.List; |
|
7 |
import java.util.Map; |
|
8 |
|
|
9 |
import org.springframework.dao.DataAccessException; |
|
10 |
import org.springframework.dao.EmptyResultDataAccessException; |
|
11 |
import org.springframework.stereotype.Service; |
|
12 |
|
6e0012
|
13 |
import com.yc.sdk.miniapp.entity.LivePushMessageApiNotifyEntity; |
a6a76f
|
14 |
import com.yc.sdk.miniapp.entity.LiveReplayVideoEntity; |
F |
15 |
import com.yc.sdk.miniapp.entity.LiveReplayVideoEntity.ReplayVideoEntity; |
|
16 |
import com.yc.sdk.miniapp.entity.LiveRoomEntity; |
|
17 |
import com.yc.sdk.miniapp.entity.LiveRoomEntity.RoomInfo; |
c19dc5
|
18 |
import com.yc.sdk.shopping.entity.CreateLiveRoomParameterStep1Entity; |
J |
19 |
import com.yc.sdk.shopping.entity.CreateLiveRoomParameterStep2Entity; |
|
20 |
import com.yc.sdk.shopping.entity.CreateLiveRoomParameterStep3Entity; |
f161ef
|
21 |
import com.yc.sdk.shopping.entity.GoodsSortInRoomEntity; |
J |
22 |
import com.yc.sdk.shopping.entity.GoodsSortInRoomPamaraterEntity; |
ae2a1f
|
23 |
import com.yc.sdk.shopping.entity.LiveSubscribeUserEntity; |
a6a76f
|
24 |
import com.yc.sdk.miniapp.entity.LiveRoomImageEntity; |
a92f52
|
25 |
import com.yc.action.grid.GridUtils; |
786635
|
26 |
import com.yc.sdk.miniapp.entity.LiveAssistantEntity; |
J |
27 |
import com.yc.sdk.miniapp.entity.LiveAssistantEntity.AssistantItemEntity; |
bff6b6
|
28 |
import com.yc.sdk.miniapp.entity.LiveGoodsEntity; |
a6a76f
|
29 |
import com.yc.service.BaseService; |
bff6b6
|
30 |
|
J |
31 |
import cn.binarywang.wx.miniapp.bean.live.WxMaAssistantResult; |
|
32 |
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveAssistantInfo; |
|
33 |
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult; |
|
34 |
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult.LiveReplay; |
a6a76f
|
35 |
|
F |
36 |
@Service("MaLiveImpl") |
|
37 |
public class MaLiveImpl extends BaseService implements MaLiveIfc { |
|
38 |
|
|
39 |
@Override |
bff6b6
|
40 |
public List<LiveRoomImageEntity> updateLiveRoom(WxMaLiveResult wxMaLiveResult) { |
a6a76f
|
41 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
F |
42 |
try{ |
|
43 |
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>(); |
|
44 |
String sql = " set nocount on ; \n" |
|
45 |
+ " declare @myRowCount int = 0 \n" |
|
46 |
+ " declare @table table(RoomId int,FieldId varchar(50), RoomImg varchar(500) ) \n" |
6b10f8
|
47 |
+ " declare @CoverImg varchar(500),@ShareImg varchar(500),@AnchorImg varchar(500),@FeedsImg varchar(500) \n" |
J |
48 |
+ " declare @CoverImgUnid varchar(500),@ShareImgUnid varchar(500),@AnchorImgUnid varchar(500),@FeedsImgUnid varchar(500) \n" |
a6a76f
|
49 |
+ " declare @DocCode varchar(20),@Type int,@UserCode varchar(50),@UserName varchar(50) \n" |
F |
50 |
+ " declare @Today datetime = convert(varchar(10),getdate(),120) \n" |
|
51 |
+ " declare @FormId int = 710701, @DocStatus int = 0 \n" |
|
52 |
+ " declare @PeriodId varchar(20),@CompanyId varchar(20),@CompanyName varchar(80),@CcCode varchar(20),@CcName varchar(50) \n" |
|
53 |
+ " declare @GoodsId bigint,@MatCode varchar(50) , @DepositDocCode varchar(50) , @DepositRowId varchar(20) \n"; |
|
54 |
|
bff6b6
|
55 |
for (int i = 0 ;wxMaLiveResult!=null&& wxMaLiveResult.getRoomInfos()!= null && i < wxMaLiveResult.getRoomInfos().size();i++) { |
J |
56 |
WxMaLiveResult.RoomInfo roomInfo = wxMaLiveResult.getRoomInfos().get(i) ; |
a6a76f
|
57 |
Date startTime = new Date(roomInfo.getStartTime()*1000) ; |
F |
58 |
Date endTime = new Date(roomInfo.getEndTime()*1000) ; |
|
59 |
|
6b10f8
|
60 |
sql += " select @DocCode = a.DocCode,@CoverImg = a.CoverImg,@ShareImg = a.ShareImg,@AnchorImg = AnchorImg,@FeedsImg = a.FeedsImg, \n" |
J |
61 |
+ " @CoverImgUnid = a.CoverImgUnid,@ShareImgUnid = a.ShareImgUnid,@AnchorImgUnid = a.AnchorImgUnid,@FeedsImgUnid = a.FeedsImgUnid \n" |
a6a76f
|
62 |
+ " from t710701 a where a.RoomId = "+ roomInfo.getRoomId() + " \n" |
F |
63 |
+ " if @@rowcount > 0 \n" |
|
64 |
+ " begin \n" |
bff6b6
|
65 |
+ " if isnull(@CoverImgUnid,'') = '' or isnull(@CoverImg,'') <> '" + (roomInfo.getCoverImg()==null?"":roomInfo.getCoverImg()) + "' \n" |
a6a76f
|
66 |
+ " begin \n" |
F |
67 |
+ " insert into @table(RoomId,FieldId,RoomImg) \n" |
bff6b6
|
68 |
+ " values (" + roomInfo.getRoomId() + ",'CoverImgUnid','" + (roomInfo.getCoverImg()==null?"":roomInfo.getCoverImg()) + "') \n" |
a6a76f
|
69 |
+ " end \n" |
bff6b6
|
70 |
+ " if isnull(@ShareImgUnid,'') = '' or isnull(@ShareImg,'') <> '" + (roomInfo.getShareImg() ==null?"":roomInfo.getShareImg()) + "' \n" |
a6a76f
|
71 |
+ " begin \n" |
F |
72 |
+ " insert into @table(RoomId,FieldId,RoomImg) \n" |
bff6b6
|
73 |
+ " values (" + roomInfo.getRoomId() + ",'ShareImgUnid','" + (roomInfo.getShareImg()==null?"":roomInfo.getShareImg()) + "') \n" |
a6a76f
|
74 |
+ " end \n" |
bff6b6
|
75 |
+ " if isnull(@AnchorImgUnid ,'') = '' or isnull(@AnchorImg,'') <> '" + (roomInfo.getAnchorImg()==null?"": roomInfo.getAnchorImg()) + "' \n" |
a6a76f
|
76 |
+ " begin \n" |
F |
77 |
+ " insert into @table(RoomId,FieldId,RoomImg) \n" |
bff6b6
|
78 |
+ " values (" + roomInfo.getRoomId() + ",'AnchorImgUnid','" + (roomInfo.getAnchorImg()==null?"":roomInfo.getAnchorImg()) + "') \n" |
a6a76f
|
79 |
+ " end \n" |
bff6b6
|
80 |
+ " if isnull(@FeedsImgUnid ,'') = '' or isnull(@FeedsImg,'') <> '" + (roomInfo.getFeedsImg()==null?"":roomInfo.getFeedsImg()) + "' \n" |
6b10f8
|
81 |
+ " begin \n" |
J |
82 |
+ " insert into @table(RoomId,FieldId,RoomImg) \n" |
bff6b6
|
83 |
+ " values (" + roomInfo.getRoomId() + ",'FeedsImgUnid','" + (roomInfo.getAnchorImg()==null?"":roomInfo.getAnchorImg()) + "') \n" |
6b10f8
|
84 |
+ " end \n" |
bff6b6
|
85 |
+ " update a set RoomName = '" + (roomInfo.getName()==null?"":roomInfo.getName()) + "',CoverImg = '" + (roomInfo.getCoverImg()==null?"":roomInfo.getCoverImg()) + "',LiveStatus=" + roomInfo.getLiveStatus() + " \n" |
J |
86 |
+ " ,StartTime = '" + format.format(startTime) + "',EndTime = '" + format.format(endTime) + "',AnchorName='" + (roomInfo.getAnchorName()==null?"":roomInfo.getAnchorName()) +"' \n" |
|
87 |
+ " ,AnchorImg='" + (roomInfo.getAnchorImg()==null?"":roomInfo.getAnchorImg()) + "',ShareImg='" + (roomInfo.getShareImg()==null?"":roomInfo.getShareImg()) + "' \n" |
|
88 |
+ " ,OpenId = case when isnull(a.OpenId,'') <> '' then a.OpenId else '" + roomInfo.getCreaterOpenid() + "' end \n" |
|
89 |
+ " ,FeedsImg='" + (roomInfo.getFeedsImg()==null?"":roomInfo.getFeedsImg()) + "', isCloseLike = " +roomInfo.getCloseLike() + ",isCloseGoods=" + roomInfo.getCloseGoods() |
|
90 |
+ " ,isCloseComment=" + roomInfo.getCloseComment() + ",isCloseReplay=" +roomInfo.getCloseReplay() |
|
91 |
//+ " ,isCloseShare="+roomInfo.getCloseShare() |
|
92 |
+ " ,isCloseKf=" + roomInfo.getCloseKf() |
|
93 |
+ " ,isFeedsPublic=" + roomInfo.getIsFeedsPublic() + "\n" |
a6a76f
|
94 |
+ " from t710701 a where a.RoomId = " + roomInfo.getRoomId() + " \n" |
F |
95 |
+ " set @myRowCount = isnull(@myRowCount,0) + @@rowcount \n" |
|
96 |
+ " end \n" ; |
|
97 |
sql += " else \n" |
|
98 |
+ " begin \n" |
|
99 |
+ " insert into @table(RoomId,FieldId,RoomImg) \n" |
bff6b6
|
100 |
+ " values (" + roomInfo.getRoomId() + ",'CoverImgUnid','" + (roomInfo.getCoverImg()==null?"":roomInfo.getCoverImg()) + "') \n" |
a6a76f
|
101 |
+ " insert into @table(RoomId,FieldId,RoomImg) \n" |
bff6b6
|
102 |
+ " values (" + roomInfo.getRoomId() + ",'ShareImgUnid','" + (roomInfo.getShareImg()==null?"":roomInfo.getShareImg()) + "') \n" |
a6a76f
|
103 |
+ " insert into @table(RoomId,FieldId,RoomImg) \n" |
bff6b6
|
104 |
+ " values (" + roomInfo.getRoomId() + ",'AnchorImgUnid','" + (roomInfo.getAnchorImg()==null?"":roomInfo.getAnchorImg()) + "') \n" |
6b10f8
|
105 |
+ " insert into @table(RoomId,FieldId,RoomImg) \n" |
bff6b6
|
106 |
+ " values (" + roomInfo.getRoomId() + ",'FeedsImgUnid','" + (roomInfo.getFeedsImg()==null?"":roomInfo.getFeedsImg()) + "') \n" |
a6a76f
|
107 |
+ " select top 1 @CompanyId = CompanyId,@CompanyName=CompanyName \n" |
F |
108 |
+ " from ocompany \n" |
|
109 |
+ " select @DocStatus = PreDocStatus from gform where formid = 710701 \n" |
|
110 |
+ " select @PeriodId = dbo.GetPeriodID(@FormId,@CompanyID,@Today) \n" |
|
111 |
+ " exec sp_newdoccode @FormId,@UserCode,@DocCode output \n" |
|
112 |
+ " insert into t710701(DocCode,FormId,DocDate,CompanyID,CompanyName,DocStatus,EnterCode,EnterName,\n" |
|
113 |
+ " EnterDate,ModifyName,ModifyDate,CcCode,CcName,PeriodId,\n" |
6b10f8
|
114 |
+ " Type,RoomId,RoomName,CoverImg,LiveStatus,StartTime,EndTime,AnchorName,AnchorImg ,ShareImg,FeedsImg,OpenId, \n" |
J |
115 |
+ " isCloseLike,isCloseGoods,isCloseComment,isCloseReplay,isCloseShare,isCloseKf,isFeedsPublic) \n" |
a6a76f
|
116 |
+ " values(@DocCode,@FormId,@Today,@CompanyID,@CompanyName,@DocStatus,@UserCode,@UserName,\n" |
F |
117 |
+ " getdate(),@UserName,getdate(),@CcCode,@CcName,@PeriodId ,\n" |
bff6b6
|
118 |
+ roomInfo.getType()+ "," + roomInfo.getRoomId() + ",'" + (roomInfo.getName()==null?"":roomInfo.getName()) + "','" + (roomInfo.getCoverImg()==null?"":roomInfo.getCoverImg()) + "'," + roomInfo.getLiveStatus() |
J |
119 |
+ " ,'" + format.format(startTime) + "','" + format.format(endTime) + "','" + (roomInfo.getAnchorName()==null?"":roomInfo.getAnchorName()) +"'," |
|
120 |
+ " '" + (roomInfo.getAnchorImg()==null?"":roomInfo.getAnchorImg()) + "','" + (roomInfo.getShareImg()==null?"": roomInfo.getShareImg()) + "','" + (roomInfo.getFeedsImg()==null?"":roomInfo.getFeedsImg()) +"','" + (roomInfo.getCreaterOpenid()==null?"":roomInfo.getCreaterOpenid()) + "', \n" |
|
121 |
+ roomInfo.getCloseLike() + "," + roomInfo.getCloseGoods() + "," |
|
122 |
+ roomInfo.getCloseComment() + "," + roomInfo.getCloseReplay() + "," |
|
123 |
+ 1 + "," + roomInfo.getCloseKf() + "," |
|
124 |
+ roomInfo.getIsFeedsPublic()+ ") \n" |
a6a76f
|
125 |
+ " set @myRowCount = isnull(@myRowCount,0) + @@rowcount \n" |
F |
126 |
+ " end \n" |
|
127 |
+ " exec p710701Save @DocCode = @DocCode \n"; |
|
128 |
|
|
129 |
//回放视频 |
bff6b6
|
130 |
for (int j = 0; wxMaLiveResult.getLiveReplay()!= null && j < wxMaLiveResult.getLiveReplay().size();j++) { |
J |
131 |
LiveReplay liveReplay = wxMaLiveResult.getLiveReplay().get(j); |
|
132 |
String createTime = liveReplay.getCreateTime().replaceAll("T"," ").replaceAll("Z","") ; |
|
133 |
String expireTime = liveReplay.getExpireTime().replaceAll("T"," ").replaceAll("Z","") ; |
|
134 |
sql += " if not exists(select 1 from t710702 where RoomId = " +roomInfo.getRoomId() + " and CreateTime = '" + createTime + "' ) \n" |
a6a76f
|
135 |
+ " begin \n" |
F |
136 |
+ " insert into t710702 (RoomId,CreateTime,ExpireTime,MediaUrl) \n" |
bff6b6
|
137 |
+ " values(" + roomInfo.getRoomId() + ",'" +createTime + "','" + expireTime + "','" + (liveReplay.getMediaUrl()==null?"":liveReplay.getMediaUrl())+"' )\n" |
a6a76f
|
138 |
+ " set @myRowCount = isnull(@myRowCount,0) + @@rowcount \n" |
F |
139 |
+ " end \n"; |
|
140 |
} |
|
141 |
|
|
142 |
//维护直播间所属商品 |
|
143 |
//sql += " delete from t710704 where RoomId = " + roomInfo.getRoomId() ; |
|
144 |
for (int j = 0 ;roomInfo.getGoods()!=null && j < roomInfo.getGoods().size();j++) { |
5efd86
|
145 |
|
J |
146 |
sql += " select @GoodsId = " + roomInfo.getGoods().get(j).getGoodsId() + " ; \n" |
|
147 |
+ " update a set MatName = '" + roomInfo.getGoods().get(j).getName() + "',\n" |
|
148 |
+ " Price = "+ roomInfo.getGoods().get(j).getPrice() + ",Price2= " + roomInfo.getGoods().get(j).getPrice2() + ",\n" |
|
149 |
+ " Url='" + roomInfo.getGoods().get(j).getUrl() + "',CoverImg='" + roomInfo.getGoods().get(j).getCoverImg() + "' \n" |
|
150 |
+ " from t710704 a \n" |
|
151 |
+ " where a.RoomId = "+ roomInfo.getRoomId() + " and a.GoodsId = @GoodsId \n" |
|
152 |
+ " if @@rowcount = 0 \n" |
|
153 |
+ " begin \n" |
|
154 |
+ " insert into t710704(RoomId,MatName,Price,Price2,Url,CoverImg,GoodsId) \n" |
|
155 |
+ " values (" + roomInfo.getRoomId() + ",'" + roomInfo.getGoods().get(j).getName() + "'," |
|
156 |
+ roomInfo.getGoods().get(j).getPrice() + "," |
|
157 |
+ roomInfo.getGoods().get(j).getPrice2()+",'" + roomInfo.getGoods().get(j).getUrl() + "','" + roomInfo.getGoods().get(j).getCoverImg()+"',@GoodsId ) \n" |
|
158 |
+ " end \n" |
|
159 |
+ " set @myRowCount = isnull(@myRowCount,0) + @@rowcount \n"; |
|
160 |
|
|
161 |
/* |
|
162 |
* 下列代码导致 t710704 有百万条记录,数据库占用急剧膨胀 , 记录 by Johns Wang,2021-07-14 |
|
163 |
定金单号 100元的做法?? ,注释 by Johns Wang,2021-07-14 |
|
164 |
|
a6a76f
|
165 |
//url 样式: pages/detailEvents/detailEvents?matcode=K-36944T-L-AF&DepositDocCode=QGDJ200413001&DepositRowId=003RXI |
F |
166 |
String url = roomInfo.getGoods().get(j).getUrl(); |
|
167 |
int pos = url.indexOf("?"); //取 ? 分隔符 |
|
168 |
String matCode = "",depositDocCode = "",depositRowId = ""; |
|
169 |
Map<String, String> queryStringMap = new HashMap<String, String>() ; |
|
170 |
if (pos > 0) { |
|
171 |
String queryString = url.substring(pos+1, url.length()) ; |
|
172 |
if (queryString != null && !"".equals(queryString)) { |
|
173 |
String tempStr[] = queryString.split("&") ; // 取& 分隔符 |
|
174 |
for(int k = 0;k < tempStr.length;k++ ) { |
|
175 |
if (tempStr[k]!=null&& !"".equals(tempStr[k])) { |
|
176 |
String subTempStr[] = tempStr[k].split("=") ; //取 = 分隔符 |
|
177 |
if (subTempStr.length >1) { |
|
178 |
queryStringMap.put(subTempStr[0], subTempStr[1]); |
|
179 |
} |
|
180 |
} |
|
181 |
} |
|
182 |
} |
|
183 |
} |
|
184 |
matCode = queryStringMap.get(SettingKey.MATCODE) ; //商品编号 |
|
185 |
depositDocCode = queryStringMap.get("DepositDocCode") ; //定金单号 |
|
186 |
depositRowId = queryStringMap.get("DepositRowId") ; //定金单行号 |
|
187 |
sql += " select @GoodsId = null,@MatCode = '" + (matCode==null?"":matCode) + "', @DepositDocCode = '" + (depositDocCode==null?"":depositDocCode)+"',@DepositRowId ='" + (depositRowId == null?"":depositRowId) + "' \n" |
|
188 |
+ " select @GoodsId = GoodsId from t710703 where isnull(MatCode,'') = isnull(@MatCode,'') \n" |
|
189 |
+ " and isnull(DepositDocCode,'') = isnull(@DepositDocCode,'') \n" |
|
190 |
+ " and isnull(DepositRowId,'') = isnull(@DepositRowId,'') \n" |
|
191 |
+ " if @@rowcount > 0 and @GoodsId is not null \n" |
|
192 |
+ " begin \n" |
|
193 |
+ " update a set MatName = '" + roomInfo.getGoods().get(j).getName() + "',\n" |
|
194 |
+ " Price = "+ roomInfo.getGoods().get(j).getPrice() + ",Price2= " + roomInfo.getGoods().get(j).getPrice2() + ",\n" |
|
195 |
+ " Url='" + roomInfo.getGoods().get(j).getUrl() + "',CoverImg='" + roomInfo.getGoods().get(j).getCoverImg() + "' \n" |
|
196 |
+ " from t710704 a \n" |
|
197 |
+ " where a.RoomId = "+ roomInfo.getRoomId() + " and a.GoodsId = @GoodsId \n" |
|
198 |
+ " if @@rowcount = 0 \n" |
|
199 |
+ " begin \n" |
|
200 |
+ " insert into t710704(RoomId,MatName,Price,Price2,Url,CoverImg,GoodsId) \n" |
|
201 |
+ " values (" + roomInfo.getRoomId() + ",'" + roomInfo.getGoods().get(j).getName() + "'," |
|
202 |
+ roomInfo.getGoods().get(j).getPrice() + "," |
|
203 |
+ roomInfo.getGoods().get(j).getPrice2()+",'" + roomInfo.getGoods().get(j).getUrl() + "','" + roomInfo.getGoods().get(j).getCoverImg()+"',@GoodsId ) \n" |
|
204 |
+ " end \n" |
|
205 |
+ " set @myRowCount = isnull(@myRowCount,0) + @@rowcount \n" |
|
206 |
+ " end else \n" |
|
207 |
+ " begin \n" |
|
208 |
+ " insert into t710704(RoomId,MatName,Price,Price2,Url,CoverImg,GoodsId) \n" |
|
209 |
+ " values (" + roomInfo.getRoomId() + ",'" + roomInfo.getGoods().get(j).getName() + "'," |
|
210 |
+ roomInfo.getGoods().get(j).getPrice() + "," |
|
211 |
+ roomInfo.getGoods().get(j).getPrice2()+",'" + roomInfo.getGoods().get(j).getUrl() + "','" + roomInfo.getGoods().get(j).getCoverImg()+"',null ) \n" |
|
212 |
+ " set @myRowCount = isnull(@myRowCount,0) + @@rowcount \n" |
|
213 |
+ " end \n"; |
5efd86
|
214 |
*/ |
6b10f8
|
215 |
} |
a6a76f
|
216 |
} |
F |
217 |
|
|
218 |
sql += " select RoomId ,FieldId , RoomImg, @myRowCount as MyRowCount from @table ;\n" ; |
a92f52
|
219 |
list = this.jdbcTemplate.queryForList(sql) ; |
a6a76f
|
220 |
List<LiveRoomImageEntity> roomInfoList = new ArrayList<LiveRoomImageEntity>() ; |
F |
221 |
for (int i = 0 ;list != null && i < list.size() ; i ++) { |
|
222 |
Map<String,Object> map = list.get(i) ; |
|
223 |
LiveRoomImageEntity roomInfo = new LiveRoomImageEntity() ; |
|
224 |
roomInfo.setRoomId(map.get("RoomId")==null?null:(Integer)map.get("RoomId")) ; |
|
225 |
roomInfo.setFieldId(map.get("FieldId")==null?null:(String)map.get("FieldId")) ; |
|
226 |
roomInfo.setRoomImg(map.get("RoomImg")==null?null:(String)map.get("RoomImg")) ; |
|
227 |
roomInfo.setRowCount(map.get("MyRowCount")==null?null:(Integer)map.get("MyRowCount")) ; |
|
228 |
roomInfoList.add(roomInfo) ; |
|
229 |
} |
|
230 |
return roomInfoList ; |
|
231 |
}catch(DataAccessException e){ |
|
232 |
if (e instanceof EmptyResultDataAccessException) { |
|
233 |
return null ; |
|
234 |
} else { |
|
235 |
//e.printStackTrace(); |
|
236 |
throw e ; |
|
237 |
} |
|
238 |
}catch(Exception e){ |
|
239 |
//e.printStackTrace(); |
|
240 |
throw e ; |
|
241 |
} |
|
242 |
} |
|
243 |
|
|
244 |
@Override |
5dc0cf
|
245 |
public Integer addGoodsToRoom(Integer roomId,String goodsIds) { |
a6a76f
|
246 |
Integer ret = null; |
F |
247 |
try { |
|
248 |
String sql = " set nocount on ; \n" |
a92f52
|
249 |
+ " declare @RoomId int = "+roomId+",@GoodsIds varchar(max) = "+GridUtils.prossSqlParm(goodsIds)+",@myRowCount int \n" |
a6a76f
|
250 |
+ " update a set MatName = b.MatName,Price = b.Price,Price2=b.Price2,Url = b.Url,CoverImg = b.CoverImgUrl \n" |
F |
251 |
+ " from t710704 a join t710703 b on a.GoodsId = b.GoodsId \n" |
|
252 |
+ " where a.RoomId = @RoomId and a.GoodsId in (select list from getinstr(@GoodsIds)) \n" |
|
253 |
+ " select @myRowCount = isnull(@myRowCount,0) + @@rowcount \n" |
|
254 |
+ " insert into t710704(RoomId,MatName,Price,Price2,Url,CoverImg,GoodsId) \n" |
|
255 |
+ " select @RoomId as RoomId,a.MatName,a.Price,a.Price2,a.Url,a.CoverImgUrl,a.GoodsId \n" |
|
256 |
+ " from t710703 a \n" |
|
257 |
+ " where a.GoodsId in (select list from getinstr(@GoodsIds)) \n" |
|
258 |
+ " and not exists(select 1 from t710704 b where b.RoomId = @RoomId and a.GoodsId = b.GoodsId ) \n" |
|
259 |
+ " select @myRowCount = isnull(@myRowCount,0) + @@rowcount \n" |
|
260 |
+ " select @myRowCount \n"; |
a92f52
|
261 |
ret = this.jdbcTemplate.queryForObject(sql, Integer.class) ; |
5dc0cf
|
262 |
} catch(DataAccessException e){ |
J |
263 |
if (e instanceof EmptyResultDataAccessException) { |
|
264 |
return 0 ; |
|
265 |
} else { |
|
266 |
//e.printStackTrace(); |
|
267 |
throw e ; |
|
268 |
} |
|
269 |
}catch(Exception e){ |
|
270 |
//e.printStackTrace(); |
|
271 |
throw e ; |
|
272 |
} |
|
273 |
return ret ; |
|
274 |
} |
|
275 |
|
|
276 |
|
|
277 |
@Override |
|
278 |
public Integer deleteGoodsInRoom(Integer roomId,Integer goodsId) { |
|
279 |
Integer ret = null; |
|
280 |
try { |
|
281 |
String sql = " set nocount on ; \n" |
a92f52
|
282 |
+ " declare @RoomId int = "+roomId+",@GoodsId int = "+goodsId+" \n" |
5dc0cf
|
283 |
+ " delete from t710704 where RoomId = @RoomId and GoodsId = @GoodsId \n" |
J |
284 |
|
|
285 |
+ " select @@rowcount \n"; |
a92f52
|
286 |
ret = this.jdbcTemplate.queryForObject(sql, Integer.class) ; |
6b10f8
|
287 |
} catch(DataAccessException e){ |
J |
288 |
if (e instanceof EmptyResultDataAccessException) { |
|
289 |
return 0 ; |
|
290 |
} else { |
|
291 |
//e.printStackTrace(); |
|
292 |
throw e ; |
|
293 |
} |
|
294 |
}catch(Exception e){ |
|
295 |
//e.printStackTrace(); |
|
296 |
throw e ; |
|
297 |
} |
|
298 |
return ret ; |
|
299 |
} |
|
300 |
|
|
301 |
@Override |
|
302 |
public Integer deleteGoods(Long goodsId) { |
|
303 |
Integer ret = null; |
|
304 |
try { |
|
305 |
String sql = " set nocount on ; \n" |
a92f52
|
306 |
+ " declare @GoodsId bigint = "+goodsId+" ,@DocCode varchar(20) \n" |
6b10f8
|
307 |
+ " select @DocCode = MatCode from t710703 where GoodsId = @GoodsId \n" |
J |
308 |
+ " delete from t710704 where GoodsId = @GoodsId \n" |
|
309 |
+ " delete from t710703 where GoodsId = @GoodsId \n" |
1f5ccf
|
310 |
+ " update a set GoodsId = null from t710802H a where a.DocCode = @DocCode \n" |
6b10f8
|
311 |
|
J |
312 |
+ " select @@rowcount \n"; |
a92f52
|
313 |
ret = this.jdbcTemplate.queryForObject(sql, Integer.class) ; |
a6a76f
|
314 |
} catch(DataAccessException e){ |
F |
315 |
if (e instanceof EmptyResultDataAccessException) { |
|
316 |
return 0 ; |
|
317 |
} else { |
|
318 |
//e.printStackTrace(); |
|
319 |
throw e ; |
|
320 |
} |
|
321 |
}catch(Exception e){ |
|
322 |
//e.printStackTrace(); |
|
323 |
throw e ; |
|
324 |
} |
|
325 |
return ret ; |
|
326 |
} |
|
327 |
|
|
328 |
@Override |
786635
|
329 |
public Integer deleteRoom(Integer roomId) { |
J |
330 |
Integer ret = null; |
|
331 |
try { |
|
332 |
String sql = " set nocount on ; \n" |
a92f52
|
333 |
+ " declare @RoomId int = "+roomId+" \n" |
786635
|
334 |
+ " delete from t710704 where RoomId = @RoomId \n" |
J |
335 |
+ " delete from t710701 where RoomId = @RoomId \n" |
|
336 |
|
|
337 |
+ " select @@rowcount \n"; |
a92f52
|
338 |
ret = this.jdbcTemplate.queryForObject(sql, Integer.class) ; |
f161ef
|
339 |
} catch(DataAccessException e){ |
J |
340 |
if (e instanceof EmptyResultDataAccessException) { |
|
341 |
return 0 ; |
|
342 |
} else { |
|
343 |
//e.printStackTrace(); |
|
344 |
throw e ; |
|
345 |
} |
|
346 |
}catch(Exception e){ |
|
347 |
//e.printStackTrace(); |
|
348 |
throw e ; |
|
349 |
} |
|
350 |
return ret ; |
|
351 |
} |
|
352 |
|
6e0012
|
353 |
|
J |
354 |
|
|
355 |
@Override |
|
356 |
public List<LiveSubscribeUserEntity> getSubscribeUsers(Integer roomId) { |
|
357 |
try { |
|
358 |
String sql = " set nocount on ; \n" |
a92f52
|
359 |
+ " declare @RoomId int = "+roomId+" \n" |
6e0012
|
360 |
+ " select a.RoomId,a.OpenId,b.NickName,b.WeiXinAvatarUnid,b.Headimgurl, \n" |
J |
361 |
+ " a.SubscribeTime,SubscribeDateTime,a.RoomStatus \n" |
|
362 |
+ " from t710708 a \n" |
|
363 |
+ " left join t730102 b on a.OpenId = b.OpenId \n" |
|
364 |
+ " where RoomId = @RoomId \n" ; |
a92f52
|
365 |
List<Map<String,Object>> list = this.jdbcTemplate.queryForList(sql) ; |
6e0012
|
366 |
List<LiveSubscribeUserEntity> liveSubscribeUserList = new ArrayList<LiveSubscribeUserEntity>(); |
J |
367 |
for (int i = 0; list !=null&& i < list.size(); i++) { |
|
368 |
Map<String,Object> map = list.get(i); |
|
369 |
LiveSubscribeUserEntity liveSubscribeUserEntity = LiveSubscribeUserEntity.builder().openId((String)map.get("OpenId")) |
|
370 |
.roomId(roomId).roomStatus((Integer)map.get("RoomStatus")) |
|
371 |
.subscribeTime(map.get("SubscribeTime")== null?0L:Long.parseLong(map.get("SubscribeTime").toString())) |
|
372 |
.subscribeDateTime(map.get("SubscribeDateTime")==null?null:(Date)map.get("SubscribeDateTime")) |
|
373 |
.build(); |
|
374 |
liveSubscribeUserList.add(liveSubscribeUserEntity); |
|
375 |
} |
|
376 |
return liveSubscribeUserList; |
|
377 |
} catch(DataAccessException e){ |
|
378 |
if (e instanceof EmptyResultDataAccessException) { |
|
379 |
return null ; |
|
380 |
} else { |
|
381 |
//e.printStackTrace(); |
|
382 |
throw e ; |
|
383 |
} |
|
384 |
}catch(Exception e){ |
|
385 |
//e.printStackTrace(); |
|
386 |
throw e ; |
|
387 |
} |
|
388 |
} |
|
389 |
|
|
390 |
|
|
391 |
|
|
392 |
|
|
393 |
@Override |
|
394 |
public Integer savePushMessageId(Integer roomId,String messageId) { |
|
395 |
try { |
|
396 |
String sql = " set nocount on ; \n" |
a92f52
|
397 |
+ " declare @RoomId int = "+roomId+" , @MessageId varchar(50) = " +GridUtils.prossSqlParm(messageId)+" \n" |
6e0012
|
398 |
+ " update a set SendDateTime = getdate() from t710709 a where a.RoomId = @RoomId and a.MessageId = @MessageId \n" |
J |
399 |
+ " if @@rowcount = 0 \n" |
|
400 |
+ " begin \n" |
|
401 |
+ " insert into t710709 (RoomId,MessageId,SendDateTime) \n" |
|
402 |
+ " values(@RoomId,@MessageId,getdate()) \n" |
|
403 |
+ " end \n" |
|
404 |
+ " select @@rowcount as myrowcount \n" ; |
a92f52
|
405 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
6e0012
|
406 |
|
J |
407 |
} catch(DataAccessException e){ |
|
408 |
if (e instanceof EmptyResultDataAccessException) { |
|
409 |
return null ; |
|
410 |
} else { |
|
411 |
//e.printStackTrace(); |
|
412 |
throw e ; |
|
413 |
} |
|
414 |
}catch(Exception e){ |
|
415 |
//e.printStackTrace(); |
|
416 |
throw e ; |
|
417 |
} |
|
418 |
} |
|
419 |
|
|
420 |
|
|
421 |
@Override |
|
422 |
public Integer savePushMessageResult(LivePushMessageApiNotifyEntity livePushMessageApiNotifyEntity) { |
|
423 |
try { |
|
424 |
String sql = " set nocount on ; \n" |
a92f52
|
425 |
+ " declare @RoomId int = "+livePushMessageApiNotifyEntity.getRoomId()+" , @MessageId varchar(50) = "+GridUtils.prossSqlParm(livePushMessageApiNotifyEntity.getMessageId()) |
J |
426 |
+",@TotalCount int = "+livePushMessageApiNotifyEntity.getTotalCount()+",@SuccessCount int = "+livePushMessageApiNotifyEntity.getSuccessCount()+" \n" |
|
427 |
+ " declare @OpenIdErrorCount int = "+livePushMessageApiNotifyEntity.getOpenidErrorCount() |
|
428 |
+",@RelationErrorCount int = "+livePushMessageApiNotifyEntity.getRelationErrorCount() |
|
429 |
+" ,@UserRecvLimitCount int = "+livePushMessageApiNotifyEntity.getUserRecvLimitCount()+" \n" |
|
430 |
+ " declare @InternalErrorCount int = "+livePushMessageApiNotifyEntity.getInternalErrorCount()+" \n" |
6e0012
|
431 |
+ " update a set TotalCount = @TotalCount,SuccessCount = @SuccessCount,OpenIdErrorCount = @OpenIdErrorCount, \n" |
J |
432 |
+ " RelationErrorCount = @RelationErrorCount,UserRecvLimitCount = @UserRecvLimitCount,InternalErrorCount = @InternalErrorCount \n" |
|
433 |
+ " from t710709 a where a.RoomId = @RoomId and a.MessageId = @MessageId \n" |
|
434 |
+ " if @@rowcount = 0 \n" |
|
435 |
+ " begin \n" |
|
436 |
+ " insert into t710709 (RoomId,MessageId,TotalCount ,SuccessCount ,OpenIdErrorCount ,RelationErrorCount ,UserRecvLimitCount,InternalErrorCount,SendDateTime) \n" |
|
437 |
+ " values(@RoomId,@MessageId,@TotalCount ,@SuccessCount ,@OpenIdErrorCount ,@RelationErrorCount ,@UserRecvLimitCount,@InternalErrorCount,getdate()) \n" |
|
438 |
+ " end \n" |
|
439 |
+ " select @@rowcount as myrowcount \n" ; |
a92f52
|
440 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
6e0012
|
441 |
|
J |
442 |
} catch(DataAccessException e){ |
|
443 |
if (e instanceof EmptyResultDataAccessException) { |
|
444 |
return null ; |
|
445 |
} else { |
|
446 |
//e.printStackTrace(); |
|
447 |
throw e ; |
|
448 |
} |
|
449 |
}catch(Exception e){ |
|
450 |
//e.printStackTrace(); |
|
451 |
throw e ; |
|
452 |
} |
|
453 |
} |
f161ef
|
454 |
|
J |
455 |
@Override |
|
456 |
public Integer deleteRoom(String docCode) { |
|
457 |
Integer ret = null; |
|
458 |
try { |
|
459 |
String sql = " set nocount on ; \n" |
a92f52
|
460 |
+ " declare @DocCode varchar(20) = "+GridUtils.prossSqlParm(docCode)+" \n" |
7a058b
|
461 |
+ " delete a from t710704 a where exists(select 1 from t710701 b where b.DocCode = @DocCode and a.RoomId = b.RoomId ) \n" |
J |
462 |
+ " delete a from t710701 a where a.DocCode = @DocCode \n" |
f161ef
|
463 |
|
J |
464 |
+ " select @@rowcount \n"; |
a92f52
|
465 |
ret = this.jdbcTemplate.queryForObject(sql, Integer.class) ; |
786635
|
466 |
} catch(DataAccessException e){ |
J |
467 |
if (e instanceof EmptyResultDataAccessException) { |
|
468 |
return 0 ; |
|
469 |
} else { |
|
470 |
//e.printStackTrace(); |
|
471 |
throw e ; |
|
472 |
} |
|
473 |
}catch(Exception e){ |
|
474 |
//e.printStackTrace(); |
|
475 |
throw e ; |
|
476 |
} |
|
477 |
return ret ; |
|
478 |
} |
|
479 |
|
|
480 |
@Override |
bff6b6
|
481 |
public Integer addAssistant(Integer roomId,List<WxMaLiveAssistantInfo> users) { |
786635
|
482 |
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") ; |
J |
483 |
String sql = " set nocount on ; \n" |
a92f52
|
484 |
+ " declare @RoomId int = "+roomId+" , @myrowcount int \n"; |
786635
|
485 |
try { |
bff6b6
|
486 |
for (int i = 0;users!=null&& i <users.size(); i++) { |
J |
487 |
WxMaLiveAssistantInfo wxMaLiveAssistantInfo = users.get(i); |
|
488 |
//AssistantItemEntity assistantItemEntity = liveAssistantEntity.getList().get(i) ; |
786635
|
489 |
Date timeStamp = null ; |
bff6b6
|
490 |
if (wxMaLiveAssistantInfo.getTimestamp() != null) { |
J |
491 |
timeStamp = new Date(wxMaLiveAssistantInfo.getTimestamp()*1000); |
786635
|
492 |
} else { |
J |
493 |
timeStamp = new Date(); |
|
494 |
} |
bff6b6
|
495 |
sql += " if not exists(select 1 from t710707 a where a.RoomId = @RoomId and UserName = '" + wxMaLiveAssistantInfo.getUsername()+"' )\n" |
786635
|
496 |
+ " begin \n" |
J |
497 |
+ " insert into t710707(RoomId,UserName,NickName,CreateTime,TimeStamp) \n" |
bff6b6
|
498 |
+ " values(@RoomId,'" + wxMaLiveAssistantInfo.getUsername()+"','"+wxMaLiveAssistantInfo.getNickname()+"','" + sdf2.format(timeStamp)+"'," +wxMaLiveAssistantInfo.getTimestamp()+") \n" |
786635
|
499 |
+ " set @myrowcount = isnull(@myrowcount,0) + 1 \n" |
J |
500 |
+ " end \n"; |
|
501 |
} |
|
502 |
sql += " select @myrowcount \n" ; |
|
503 |
|
a92f52
|
504 |
Integer ret = this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
786635
|
505 |
|
J |
506 |
return ret ; |
|
507 |
} catch(DataAccessException e){ |
|
508 |
if (e instanceof EmptyResultDataAccessException) { |
|
509 |
return null ; |
|
510 |
} else { |
|
511 |
//e.printStackTrace(); |
|
512 |
throw e ; |
|
513 |
} |
|
514 |
}catch(Exception e){ |
|
515 |
//e.printStackTrace(); |
|
516 |
throw e ; |
|
517 |
} |
|
518 |
} |
|
519 |
|
|
520 |
@Override |
bff6b6
|
521 |
public Integer updateAssistantOpenId(Integer roomId ,List<WxMaAssistantResult.Assistant> assistantList) { |
786635
|
522 |
String sql = " set nocount on ; \n" |
a92f52
|
523 |
+ " declare @RoomId int = "+roomId+" , @myrowcount int \n"; |
786635
|
524 |
try { |
bff6b6
|
525 |
for (int i = 0;assistantList!=null&& i <assistantList.size(); i++) { |
J |
526 |
WxMaAssistantResult.Assistant assistant = assistantList.get(i); |
786635
|
527 |
|
bff6b6
|
528 |
|
a92f52
|
529 |
sql += " update a set OpenId ="+GridUtils.prossSqlParm(assistant.getOpenid()) + " from t710707 a where a.RoomId = @RoomId and NickName = " + GridUtils.prossSqlParm(assistant.getNickname()) +" \n" |
786635
|
530 |
+ " set @myrowcount = isnull(@myrowcount,0) + 1 \n"; |
J |
531 |
} |
|
532 |
sql += " select @myrowcount \n" ; |
|
533 |
|
a92f52
|
534 |
Integer ret = this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
786635
|
535 |
|
J |
536 |
return ret ; |
|
537 |
} catch(DataAccessException e){ |
|
538 |
if (e instanceof EmptyResultDataAccessException) { |
|
539 |
return null ; |
|
540 |
} else { |
|
541 |
//e.printStackTrace(); |
|
542 |
throw e ; |
|
543 |
} |
|
544 |
}catch(Exception e){ |
|
545 |
//e.printStackTrace(); |
|
546 |
throw e ; |
|
547 |
} |
|
548 |
} |
|
549 |
|
|
550 |
@Override |
|
551 |
public Integer updateAssistant(Integer roomId,String userName,String nickName) { |
|
552 |
String sql = " set nocount on ; \n" |
a92f52
|
553 |
+ " declare @RoomId int = "+roomId+" , @UserName nvarchar(200) = "+GridUtils.prossSqlParm(userName)+",@NickName nvarchar(400) = "+GridUtils.prossSqlParm(nickName) +" \n" |
786635
|
554 |
+ " update a set NickName = @NickName from t710707 a where a.RoomId = RoomId and a.UserName = @UserName \n" |
J |
555 |
+ " select @@rowcount \n"; |
|
556 |
try { |
a92f52
|
557 |
Integer ret = this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
786635
|
558 |
return ret ; |
J |
559 |
} catch(DataAccessException e){ |
|
560 |
if (e instanceof EmptyResultDataAccessException) { |
|
561 |
return null ; |
|
562 |
} else { |
|
563 |
//e.printStackTrace(); |
|
564 |
throw e ; |
|
565 |
} |
|
566 |
}catch(Exception e){ |
|
567 |
//e.printStackTrace(); |
|
568 |
throw e ; |
|
569 |
} |
|
570 |
} |
|
571 |
|
|
572 |
@Override |
|
573 |
public Integer deleteAssistant(Integer roomId,String userName) { |
|
574 |
String sql = " set nocount on ; \n" |
a92f52
|
575 |
+ " declare @RoomId int = "+roomId+" , @UserName varchar(50) = "+GridUtils.prossSqlParm(userName)+ " \n" |
786635
|
576 |
+ " delete a from t710707 a where a.RoomId = @RoomId and a.UserName = @UserName \n" |
J |
577 |
+ " select @@rowcount \n"; |
|
578 |
try { |
a92f52
|
579 |
Integer ret = this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
786635
|
580 |
return ret ; |
J |
581 |
} catch(DataAccessException e){ |
|
582 |
if (e instanceof EmptyResultDataAccessException) { |
|
583 |
return null ; |
|
584 |
} else { |
|
585 |
//e.printStackTrace(); |
|
586 |
throw e ; |
|
587 |
} |
|
588 |
}catch(Exception e){ |
|
589 |
//e.printStackTrace(); |
|
590 |
throw e ; |
|
591 |
} |
|
592 |
} |
|
593 |
|
|
594 |
@Override |
|
595 |
public LiveAssistantEntity getAssistantList(Integer roomId) { |
|
596 |
String sql = " set nocount on ; \n" |
a92f52
|
597 |
+ " declare @RoomId int = "+roomId+" \n" |
786635
|
598 |
+ " select a.RoomId,a.UserName,a.NickName,a.CreateTime,a.OpenId,a.TimeStamp \n" |
J |
599 |
+ " from t710707 a where RoomId = @RoomId order by a.CreateTime asc \n"; |
|
600 |
try { |
|
601 |
LiveAssistantEntity liveAssistantEntity = new LiveAssistantEntity() ; |
a92f52
|
602 |
List<Map<String,Object>> list = this.jdbcTemplate.queryForList(sql) ; |
786635
|
603 |
List<AssistantItemEntity> assistantItemList = new ArrayList<AssistantItemEntity>() ; |
J |
604 |
for (int i = 0;list!=null&& i < list.size(); i++) { |
|
605 |
Map<String,Object> map = list.get(i) ; |
|
606 |
AssistantItemEntity assistantItemEntity = liveAssistantEntity.new AssistantItemEntity() ; |
|
607 |
assistantItemEntity.setUserName(map.get("UserName")== null?"":(String)map.get("UserName")); |
|
608 |
assistantItemEntity.setNickName(map.get("NickName")== null?"":(String)map.get("NickName")); |
|
609 |
assistantItemEntity.setCreateTime(map.get("CreateTime")== null?null:(Date)map.get("CreateTime")); |
|
610 |
assistantItemEntity.setOpenId(map.get("OpenId")== null?"":(String)map.get("OpenId")); |
|
611 |
assistantItemEntity.setTimeStamp(map.get("TimeStamp")== null?0L:Long.parseLong(map.get("TimeStamp").toString())); |
|
612 |
|
|
613 |
assistantItemList.add(assistantItemEntity); |
|
614 |
} |
|
615 |
liveAssistantEntity.setList(assistantItemList); |
|
616 |
liveAssistantEntity.setRoomId(roomId); |
|
617 |
return liveAssistantEntity ; |
|
618 |
} catch(DataAccessException e){ |
|
619 |
if (e instanceof EmptyResultDataAccessException) { |
|
620 |
return null ; |
|
621 |
} else { |
|
622 |
//e.printStackTrace(); |
|
623 |
throw e ; |
|
624 |
} |
|
625 |
}catch(Exception e){ |
|
626 |
//e.printStackTrace(); |
|
627 |
throw e ; |
|
628 |
} |
|
629 |
} |
|
630 |
|
|
631 |
|
|
632 |
@Override |
|
633 |
public Integer updateSubAnchor(Integer roomId,String userName) { |
|
634 |
String sql = " set nocount on ; \n" |
a92f52
|
635 |
+ " declare @RoomId int = "+roomId+" , @UserName varchar(50) = "+GridUtils.prossSqlParm(userName)+" \n" |
786635
|
636 |
+ " update a set SubAnchorWechat = @UserName from t710701 a where a.RoomId = @RoomId \n" |
J |
637 |
+ " select @@rowcount \n"; |
|
638 |
try { |
a92f52
|
639 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
786635
|
640 |
|
J |
641 |
}catch(DataAccessException e){ |
|
642 |
if (e instanceof EmptyResultDataAccessException) { |
|
643 |
return null ; |
|
644 |
} else { |
|
645 |
throw e ; |
|
646 |
} |
|
647 |
}catch(Exception e){ |
|
648 |
throw e ; |
|
649 |
} |
|
650 |
} |
|
651 |
|
|
652 |
@Override |
|
653 |
public Integer updateFeedsPublic(Integer roomId,Integer isFeedsPublic ) { |
|
654 |
String sql = " set nocount on ; \n" |
a92f52
|
655 |
+ " declare @RoomId int = "+roomId+" , @isFeedsPublic int = "+isFeedsPublic+" \n" |
786635
|
656 |
+ " update a set isFeedsPublic = @isFeedsPublic from t710701 a where a.RoomId = @RoomId \n" |
J |
657 |
+ " select @@rowcount \n"; |
|
658 |
try { |
a92f52
|
659 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
786635
|
660 |
|
J |
661 |
}catch(DataAccessException e){ |
|
662 |
if (e instanceof EmptyResultDataAccessException) { |
|
663 |
return null ; |
|
664 |
} else { |
|
665 |
throw e ; |
|
666 |
} |
|
667 |
}catch(Exception e){ |
|
668 |
throw e ; |
|
669 |
} |
|
670 |
} |
|
671 |
|
|
672 |
@Override |
|
673 |
public Integer updateCloseReplay(Integer roomId,Integer isCloseReplay ) { |
|
674 |
String sql = " set nocount on ; \n" |
a92f52
|
675 |
+ " declare @RoomId int = "+roomId+" , @isCloseReplay int = "+isCloseReplay+" \n" |
786635
|
676 |
+ " update a set isCloseReplay = @isCloseReplay from t710701 a where a.RoomId = @RoomId \n" |
J |
677 |
+ " select @@rowcount \n"; |
|
678 |
try { |
a92f52
|
679 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
786635
|
680 |
|
J |
681 |
}catch(DataAccessException e){ |
|
682 |
if (e instanceof EmptyResultDataAccessException) { |
|
683 |
return null ; |
|
684 |
} else { |
|
685 |
throw e ; |
|
686 |
} |
|
687 |
}catch(Exception e){ |
|
688 |
throw e ; |
|
689 |
} |
|
690 |
} |
|
691 |
|
|
692 |
@Override |
|
693 |
public Integer updateCloseKf(Integer roomId,Integer isCloseKf ) { |
|
694 |
String sql = " set nocount on ; \n" |
a92f52
|
695 |
+ " declare @RoomId int = "+roomId+" , @isCloseKf int = "+isCloseKf+" \n" |
786635
|
696 |
+ " update a set isCloseKf = @isCloseKf from t710701 a where a.RoomId = @RoomId \n" |
J |
697 |
+ " select @@rowcount \n"; |
|
698 |
try { |
a92f52
|
699 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
786635
|
700 |
|
J |
701 |
}catch(DataAccessException e){ |
|
702 |
if (e instanceof EmptyResultDataAccessException) { |
|
703 |
return null ; |
|
704 |
} else { |
|
705 |
throw e ; |
|
706 |
} |
|
707 |
}catch(Exception e){ |
|
708 |
throw e ; |
|
709 |
} |
|
710 |
} |
|
711 |
|
|
712 |
@Override |
|
713 |
public Integer updateCloseComment(Integer roomId,Integer isCloseComment ) { |
|
714 |
String sql = " set nocount on ; \n" |
a92f52
|
715 |
+ " declare @RoomId int = "+roomId+" , @isCloseComment int = "+isCloseComment+" \n" |
786635
|
716 |
+ " update a set isCloseComment = @isCloseComment from t710701 a where a.RoomId = @RoomId \n" |
J |
717 |
+ " select @@rowcount \n"; |
|
718 |
try { |
a92f52
|
719 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
786635
|
720 |
|
J |
721 |
}catch(DataAccessException e){ |
|
722 |
if (e instanceof EmptyResultDataAccessException) { |
|
723 |
return null ; |
|
724 |
} else { |
|
725 |
throw e ; |
|
726 |
} |
|
727 |
}catch(Exception e){ |
|
728 |
throw e ; |
|
729 |
} |
|
730 |
} |
|
731 |
|
|
732 |
@Override |
ae2a1f
|
733 |
public Integer updateGoodsToOnSaleInRoom(Integer roomId,Long goodsId,Integer onSale ) { |
786635
|
734 |
String sql = " set nocount on ; \n" |
a92f52
|
735 |
+ " declare @RoomId int = "+roomId+" ,@GoodsId bigint = "+goodsId+", @onSale int = "+onSale+" \n" |
786635
|
736 |
+ " update a set onSale = @onSale from t710704 a where a.RoomId = @RoomId and a.GoodsId = @GoodsId \n" |
J |
737 |
+ " select @@rowcount \n"; |
|
738 |
try { |
a92f52
|
739 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
786635
|
740 |
|
J |
741 |
}catch(DataAccessException e){ |
|
742 |
if (e instanceof EmptyResultDataAccessException) { |
|
743 |
return null ; |
|
744 |
} else { |
|
745 |
throw e ; |
|
746 |
} |
|
747 |
}catch(Exception e){ |
|
748 |
throw e ; |
|
749 |
} |
|
750 |
} |
|
751 |
|
|
752 |
|
|
753 |
@Override |
a6a76f
|
754 |
public Integer updateRoomImg(LiveRoomImageEntity liveRoomImageEntity) { |
F |
755 |
Integer ret = null; |
|
756 |
try { |
|
757 |
String sql = " set nocount on ; \n" |
a92f52
|
758 |
+ " declare @RoomImgUnid varchar(50) = "+GridUtils.prossSqlParm(liveRoomImageEntity.getRoomImgUnid())+" ,@RoomId int = "+liveRoomImageEntity.getRoomId()+" ,@myRowCount int = 0 \n" |
a6a76f
|
759 |
+ " update a set " + liveRoomImageEntity.getFieldId() + " = @RoomImgUnid from t710701 a where a.RoomId = @RoomId \n" |
F |
760 |
+ " set @myRowCount = @@rowcount \n" |
|
761 |
+ " select @myRowCount ;" ; |
a92f52
|
762 |
ret = this.jdbcTemplate.queryForObject(sql, Integer.class) ; |
a6a76f
|
763 |
}catch(DataAccessException e){ |
F |
764 |
if (e instanceof EmptyResultDataAccessException) { |
|
765 |
return 0 ; |
|
766 |
} else { |
|
767 |
//e.printStackTrace(); |
|
768 |
throw e ; |
|
769 |
} |
|
770 |
}catch(Exception e){ |
|
771 |
//e.printStackTrace(); |
|
772 |
throw e ; |
|
773 |
} |
|
774 |
return ret ; |
|
775 |
} |
c02895
|
776 |
|
J |
777 |
@Override |
|
778 |
public Integer updateRoomQrCodeUrl(Integer roomId,String roomQrCodeUrl,String roomQrCodeUrlUnid) { |
|
779 |
Integer ret = null; |
|
780 |
try { |
|
781 |
String sql = " set nocount on ; \n" |
a92f52
|
782 |
+ " declare @RoomId int = "+roomId+",@RoomQrCodeUrl varchar(500) = "+GridUtils.prossSqlParm(roomQrCodeUrl)+" ,@RoomQrCodeUrlUnid varchar(50) = "+GridUtils.prossSqlParm(roomQrCodeUrlUnid)+" , @myRowCount int = 0 \n" |
c02895
|
783 |
+ " update a set RoomQrCodeUrl = @RoomQrCodeUrl,RoomQrCodeUrlUnid = @RoomQrCodeUrlUnid from t710701 a where a.RoomId = @RoomId \n" |
J |
784 |
+ " set @myRowCount = @@rowcount \n" |
|
785 |
+ " select @myRowCount ;" ; |
a92f52
|
786 |
ret = this.jdbcTemplate.queryForObject(sql, Integer.class) ; |
c02895
|
787 |
}catch(DataAccessException e){ |
J |
788 |
if (e instanceof EmptyResultDataAccessException) { |
|
789 |
return 0 ; |
|
790 |
} else { |
|
791 |
//e.printStackTrace(); |
|
792 |
throw e ; |
|
793 |
} |
|
794 |
}catch(Exception e){ |
|
795 |
//e.printStackTrace(); |
|
796 |
throw e ; |
|
797 |
} |
|
798 |
return ret ; |
|
799 |
} |
a6a76f
|
800 |
|
F |
801 |
@Override |
bff6b6
|
802 |
public Integer updateReplayVideo(Integer roomId,List<LiveReplay> liveReplayList) { |
a6a76f
|
803 |
Integer ret = null; |
F |
804 |
try { |
|
805 |
String sql = " set nocount on ; \n" |
|
806 |
+ " declare @myRowCount int = 0 \n" ; |
bff6b6
|
807 |
for (int i =0; liveReplayList != null && i <liveReplayList.size();i++ ) { |
J |
808 |
LiveReplay liveReplay = liveReplayList.get(i) ; |
a6a76f
|
809 |
|
bff6b6
|
810 |
|
J |
811 |
sql += " if not exists(select 1 from t710702 where RoomId = " +roomId + " and CreateTime = '" + liveReplay.getCreateTime() + "' ) \n" |
a6a76f
|
812 |
+ " begin \n" |
F |
813 |
+ " insert into t710702 (RoomId,CreateTime,ExpireTime,MediaUrl) \n" |
bff6b6
|
814 |
+ " values(" + roomId + ",'" + liveReplay.getCreateTime() + "','" + liveReplay.getExpireTime() + "','" +liveReplay.getMediaUrl()+"' )\n" |
a6a76f
|
815 |
+ " set @myRowCount = isnull(@myRowCount,0) + 1 \n" |
F |
816 |
+ " end \n"; |
|
817 |
} |
|
818 |
sql += " select @myRowCount ;" ; |
a92f52
|
819 |
ret = this.jdbcTemplate.queryForObject(sql, Integer.class) ; |
a6a76f
|
820 |
}catch(DataAccessException e){ |
F |
821 |
if (e instanceof EmptyResultDataAccessException) { |
|
822 |
return 0 ; |
|
823 |
} else { |
|
824 |
//e.printStackTrace(); |
|
825 |
throw e ; |
|
826 |
} |
|
827 |
}catch(Exception e){ |
|
828 |
//e.printStackTrace(); |
|
829 |
throw e ; |
|
830 |
} |
|
831 |
return ret ; |
|
832 |
} |
|
833 |
|
|
834 |
@Override |
|
835 |
public Integer saveRoomStep2(RoomInfo roomInfo) { |
|
836 |
String sql = " set nocount on ; \n" |
a92f52
|
837 |
+ " declare @DocCode varchar(20) = "+GridUtils.prossSqlParm(roomInfo.getDocCode())+",@isCloseLike int ="+roomInfo.getCloseLike()+",@isCloseGoods int ="+roomInfo.getCloseGoods()+" \n" |
a6a76f
|
838 |
+ " declare @myrowcount int \n" |
a92f52
|
839 |
+ " declare @isCloseComment int ="+roomInfo.getCloseComment()+",@isCloseReplay int = "+roomInfo.getCloseReplay()+",@isCloseShare int = "+roomInfo.getCloseShare()+",@isCloseKf int = "+roomInfo.getCloseKf()+",@isFeedsPublic int = "+roomInfo.getIsFeedsPublic()+" \n" |
a6a76f
|
840 |
+ " update a set isCloseLike = @isCloseLike,isCloseGoods=@isCloseGoods,isCloseComment=@isCloseComment, \n" |
786635
|
841 |
+ " isCloseReplay=@isCloseReplay,isCloseShare=@isCloseShare,isCloseKf=@isCloseKf,isFeedsPublic = @isFeedsPublic \n" |
a6a76f
|
842 |
+ " from t710701 a where a.DocCode = @DocCode \n" |
F |
843 |
+ " select @myrowcount = @@rowcount \n" |
|
844 |
+ " exec p710701Save @DocCode = @DocCode \n" |
|
845 |
+ " select @myrowcount \n"; |
|
846 |
try { |
a92f52
|
847 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
a6a76f
|
848 |
|
F |
849 |
}catch(DataAccessException e){ |
|
850 |
if (e instanceof EmptyResultDataAccessException) { |
|
851 |
return null ; |
|
852 |
} else { |
|
853 |
throw e ; |
|
854 |
} |
|
855 |
}catch(Exception e){ |
|
856 |
throw e ; |
|
857 |
} |
|
858 |
} |
|
859 |
|
|
860 |
@Override |
|
861 |
public String saveRoomStep1(RoomInfo roomInfo) { |
a92f52
|
862 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
J |
863 |
|
a6a76f
|
864 |
String sql = " set nocount on ; \n" |
a92f52
|
865 |
+ " declare @DocCode varchar(20) = "+GridUtils.prossSqlParm(roomInfo.getDocCode())+",@Type int = "+roomInfo.getType() |
J |
866 |
+",@RoomName varchar(80) = "+GridUtils.prossSqlParm(roomInfo.getName()) |
|
867 |
+",@StartTime datetime = "+GridUtils.prossSqlParm(roomInfo.getStartDateTime()==null?null:sdf.format(roomInfo.getStartDateTime())) |
|
868 |
+",@EndTime datetime = "+GridUtils.prossSqlParm(roomInfo.getEndDateTime()==null?null:sdf.format(roomInfo.getEndDateTime()))+" \n" |
|
869 |
+ " declare @AnchorName varchar(50) = "+GridUtils.prossSqlParm(roomInfo.getAnchorName()) |
|
870 |
+",@AnchorWechat varchar(200) ="+GridUtils.prossSqlParm(roomInfo.getAnchorWechat()) |
|
871 |
+",@SubAnchorWechat varchar(200) ="+GridUtils.prossSqlParm(roomInfo.getSubAnchorWechat()) |
|
872 |
+",@isFeedsPublic int = "+roomInfo.getIsFeedsPublic()+" \n" |
|
873 |
+ " declare @ScreenType int = "+roomInfo.getScreenType()+",@UserCode varchar(50) = "+GridUtils.prossSqlParm(roomInfo.getUserCode()) |
|
874 |
+", @UserName varchar(50) = "+GridUtils.prossSqlParm(roomInfo.getUserName())+",@ShopCcCode varchar(50) = "+GridUtils.prossSqlParm(roomInfo.getShopCcCode())+" \n" |
|
875 |
+ " declare @isShowBannerPhotoOnHomePage int = "+(roomInfo.isShowBannerPhotoOnHomePage()?1:0)+" ,@OpenId varchar(200) = "+GridUtils.prossSqlParm(roomInfo.getCreaterWechat()) +" \n" |
a6a76f
|
876 |
+ " declare @Today datetime = convert(varchar(10),getdate(),120) \n" |
F |
877 |
+ " declare @FormId int = 710701, @DocStatus int = 0 ,@isFound int = 0 \n" |
|
878 |
|
|
879 |
+ " declare @DefaultBrand varchar(50) \n" |
|
880 |
+ " select top 1 @DefaultBrand = DefaultBrand from _sys_LoginUser where UserCode = @UserCode \n" |
|
881 |
|
|
882 |
+ " declare @PeriodId varchar(20),@CompanyId varchar(20),@CompanyName varchar(80),@CcCode varchar(20),@CcName varchar(50) \n" |
|
883 |
+ " if isnull(@DocCode,'') <> '' \n" |
|
884 |
+ " begin \n" |
|
885 |
+ " update a set Type=@Type,RoomName = @RoomName,StartTime = @StartTime,EndTime=@EndTime,AnchorName=@AnchorName,\n" |
|
886 |
+ " AnchorWechat=@AnchorWechat,SubAnchorWechat=@SubAnchorWechat,isFeedsPublic=@isFeedsPublic,ScreenType=@ScreenType,ShopCcCode=@ShopCcCode, \n" |
|
887 |
+ " ModifyName = @UserName,ModifyDate = getdate(),Brand = @DefaultBrand,isShowBannerPhotoOnHomePage = @isShowBannerPhotoOnHomePage \n" |
|
888 |
+ " from t710701 a where a.DocCode = @DocCode \n" |
|
889 |
+ " set @isFound = @@rowcount \n" |
|
890 |
+ " end \n" |
|
891 |
+ " if isnull(@isFound,0) = 0 \n" |
|
892 |
+ " begin \n" |
|
893 |
+ " select @CcCode = CcCode,@CompanyId = CompanyId,@CompanyName=CompanyName,@UserName = UserName \n" |
|
894 |
+ " from _sys_loginuser a where usercode = @UserCode \n" |
|
895 |
+ " select @DocStatus = PreDocStatus from gform where formid = 710701 \n" |
|
896 |
+ " select @PeriodId = dbo.GetPeriodID(@FormId,@CompanyID,@Today) \n" |
|
897 |
+ " exec sp_newdoccode @FormId,@UserCode,@DocCode output \n" |
|
898 |
+ " insert into t710701(DocCode,FormId,DocDate,CompanyID,CompanyName,DocStatus,EnterCode,EnterName,\n" |
|
899 |
+ " EnterDate,ModifyName,ModifyDate,CcCode,CcName,PeriodId, \n" |
64db07
|
900 |
+ " Type,RoomId,RoomName,StartTime,EndTime,AnchorName,AnchorWechat,SubAnchorWechat,isFeedsPublic, \n" |
J |
901 |
+ " ScreenType,ShopCcCode,Brand,isShowBannerPhotoOnHomePage,OpenId) \n" |
a6a76f
|
902 |
+ " values(@DocCode,@FormId,@Today,@CompanyID,@CompanyName,@DocStatus,@UserCode,@UserName,\n" |
F |
903 |
+ " getdate(),@UserName,getdate(),@CcCode,@CcName,@PeriodId ,\n" |
64db07
|
904 |
+ " @Type,null,@RoomName,@StartTime,@EndTime,@AnchorName,@AnchorWechat,@SubAnchorWechat,@isFeedsPublic, \n" |
J |
905 |
+ " @ScreenType,@ShopCcCode,@DefaultBrand,@isShowBannerPhotoOnHomePage,@OpenId) \n" |
a6a76f
|
906 |
+ " end \n" |
F |
907 |
+ " exec p710701Save @DocCode = @DocCode \n" |
|
908 |
+ " select @DocCode as DocCode \n" ; |
|
909 |
try { |
a92f52
|
910 |
Map<String, Object> map = this.jdbcTemplate.queryForMap(sql) ; |
a6a76f
|
911 |
String docCode = null ; |
F |
912 |
if (map != null) { |
|
913 |
docCode= (String)map.get("DocCode") ; |
|
914 |
} |
|
915 |
return docCode; |
|
916 |
}catch(DataAccessException e){ |
|
917 |
if (e instanceof EmptyResultDataAccessException) { |
|
918 |
return null ; |
|
919 |
} else { |
|
920 |
throw e ; |
|
921 |
} |
|
922 |
}catch(Exception e){ |
|
923 |
throw e ; |
|
924 |
} |
|
925 |
|
|
926 |
} |
|
927 |
|
c19dc5
|
928 |
|
J |
929 |
@Override |
|
930 |
public String createRoomStep1(CreateLiveRoomParameterStep1Entity createLiveRoomParameterStep1Entity) { |
|
931 |
String sql = " set nocount on ; \n" |
a92f52
|
932 |
+ " declare @DocCode varchar(20) = "+GridUtils.prossSqlParm(createLiveRoomParameterStep1Entity.getDocCode())+",@Type int = "+createLiveRoomParameterStep1Entity.getType()+",@RoomName varchar(80) = "+GridUtils.prossSqlParm(createLiveRoomParameterStep1Entity.getName())+" \n" |
J |
933 |
+ " declare @AnchorName varchar(50) = "+GridUtils.prossSqlParm(createLiveRoomParameterStep1Entity.getAnchorName()) |
|
934 |
+",@AnchorWechat varchar(200) ="+GridUtils.prossSqlParm(createLiveRoomParameterStep1Entity.getAnchorWechat()) |
|
935 |
+",@SubAnchorWechat varchar(200) ="+GridUtils.prossSqlParm(createLiveRoomParameterStep1Entity.getSubAnchorWechat())+" \n" |
|
936 |
+ " declare @ScreenType int = "+createLiveRoomParameterStep1Entity.getScreenType() |
|
937 |
+",@UserCode varchar(50) = "+GridUtils.prossSqlParm(createLiveRoomParameterStep1Entity.getUserCode()) |
|
938 |
+", @UserName varchar(50) = "+GridUtils.prossSqlParm(createLiveRoomParameterStep1Entity.getUserName()) |
|
939 |
+",@ShopCcCode varchar(50) = "+GridUtils.prossSqlParm(createLiveRoomParameterStep1Entity.getShopCcCode()) +" \n" |
|
940 |
+ " declare @isShowBannerPhotoOnHomePage int = 0 ,@OpenId varchar(200) = "+GridUtils.prossSqlParm(createLiveRoomParameterStep1Entity.getOpenId())+" \n" |
|
941 |
+ " declare @ShareImgUnid varchar(50) = "+GridUtils.prossSqlParm(createLiveRoomParameterStep1Entity.getShareImgUnid()) |
|
942 |
+",@FeedsImgUnid varchar(50) = "+GridUtils.prossSqlParm(createLiveRoomParameterStep1Entity.getFeedsImgUnid()) |
|
943 |
+",@CoverImgUnid varchar(50) = "+GridUtils.prossSqlParm(createLiveRoomParameterStep1Entity.getCoverImgUnid()) +" \n" |
c19dc5
|
944 |
+ " declare @Today datetime = convert(varchar(10),getdate(),120) \n" |
J |
945 |
+ " declare @FormId int = 710701, @DocStatus int = 0 ,@isFound int = 0 \n" |
|
946 |
|
|
947 |
+ " declare @DefaultBrand varchar(50) \n" |
|
948 |
+ " select top 1 @DefaultBrand = DefaultBrand from _sys_LoginUser where UserCode = @UserCode \n" |
|
949 |
|
|
950 |
+ " declare @PeriodId varchar(20),@CompanyId varchar(20),@CompanyName varchar(80),@CcCode varchar(20),@CcName varchar(50) \n" |
|
951 |
+ " if isnull(@DocCode,'') <> '' \n" |
|
952 |
+ " begin \n" |
|
953 |
+ " update a set Type=@Type,RoomName = @RoomName,AnchorName=@AnchorName,\n" |
|
954 |
+ " AnchorWechat=@AnchorWechat,SubAnchorWechat=@SubAnchorWechat,ScreenType=@ScreenType,ShopCcCode=@ShopCcCode, \n" |
|
955 |
+ " ModifyName = @UserName,ModifyDate = getdate(),Brand = @DefaultBrand,isShowBannerPhotoOnHomePage = @isShowBannerPhotoOnHomePage, \n" |
|
956 |
+ " ShareImgUnid = @ShareImgUnid,FeedsImgUnid = @FeedsImgUnid,CoverImgUnid = @CoverImgUnid \n" |
|
957 |
+ " from t710701 a where a.DocCode = @DocCode \n" |
|
958 |
+ " set @isFound = @@rowcount \n" |
|
959 |
+ " end \n" |
|
960 |
+ " if isnull(@isFound,0) = 0 \n" |
|
961 |
+ " begin \n" |
|
962 |
+ " select @CcCode = CcCode,@CompanyId = CompanyId,@CompanyName=CompanyName,@UserName = UserName \n" |
|
963 |
+ " from _sys_loginuser a where usercode = @UserCode \n" |
|
964 |
+ " select @DocStatus = PreDocStatus from gform where formid = 710701 \n" |
|
965 |
+ " select @PeriodId = dbo.GetPeriodID(@FormId,@CompanyID,@Today) \n" |
|
966 |
+ " exec sp_newdoccode @FormId,@UserCode,@DocCode output \n" |
|
967 |
+ " insert into t710701(DocCode,FormId,DocDate,CompanyID,CompanyName,DocStatus,EnterCode,EnterName,\n" |
|
968 |
+ " EnterDate,ModifyName,ModifyDate,CcCode,CcName,PeriodId, \n" |
|
969 |
+ " Type,RoomId,RoomName,AnchorName,AnchorWechat,SubAnchorWechat,\n" |
|
970 |
+ " ScreenType,ShopCcCode,Brand,isShowBannerPhotoOnHomePage,OpenId, \n" |
|
971 |
+ " ShareImgUnid ,FeedsImgUnid ,CoverImgUnid) \n" |
|
972 |
+ " values(@DocCode,@FormId,@Today,@CompanyID,@CompanyName,@DocStatus,@UserCode,@UserName,\n" |
|
973 |
+ " getdate(),@UserName,getdate(),@CcCode,@CcName,@PeriodId ,\n" |
7a058b
|
974 |
+ " @Type,null,@RoomName,@AnchorName,@AnchorWechat,@SubAnchorWechat, \n" |
c19dc5
|
975 |
+ " @ScreenType,@ShopCcCode,@DefaultBrand,@isShowBannerPhotoOnHomePage,@OpenId , \n" |
J |
976 |
+ " @ShareImgUnid ,@FeedsImgUnid ,@CoverImgUnid ) \n" |
|
977 |
+ " end \n" |
|
978 |
+ " exec p710701Save @DocCode = @DocCode \n" |
|
979 |
+ " select @DocCode as DocCode \n" ; |
|
980 |
try { |
a92f52
|
981 |
Map<String, Object> map = this.jdbcTemplate.queryForMap(sql) ; |
c19dc5
|
982 |
String docCode = null ; |
J |
983 |
if (map != null) { |
|
984 |
docCode= (String)map.get("DocCode") ; |
|
985 |
} |
|
986 |
return docCode; |
|
987 |
}catch(DataAccessException e){ |
|
988 |
if (e instanceof EmptyResultDataAccessException) { |
|
989 |
return null ; |
|
990 |
} else { |
|
991 |
throw e ; |
|
992 |
} |
|
993 |
}catch(Exception e){ |
|
994 |
throw e ; |
|
995 |
} |
|
996 |
|
|
997 |
} |
a6a76f
|
998 |
|
F |
999 |
|
|
1000 |
@Override |
c19dc5
|
1001 |
public Integer createRoomStep2(CreateLiveRoomParameterStep2Entity createLiveRoomParameterStep2Entity) { |
J |
1002 |
String sql = " set nocount on ; \n" |
a92f52
|
1003 |
+ " declare @DocCode varchar(20) = "+GridUtils.prossSqlParm(createLiveRoomParameterStep2Entity.getDocCode()) |
J |
1004 |
+",@isCloseComment int ="+createLiveRoomParameterStep2Entity.getCloseComment() |
|
1005 |
+",@isCloseLike int ="+createLiveRoomParameterStep2Entity.getCloseLike() |
|
1006 |
+",@isCloseShare int = "+createLiveRoomParameterStep2Entity.getCloseShare()+" \n" |
|
1007 |
+ " declare @isCloseReplay int = "+createLiveRoomParameterStep2Entity.getCloseReplay() |
|
1008 |
+",@isCloseKf int = "+createLiveRoomParameterStep2Entity.getCloseKf() |
|
1009 |
+",@isCloseGoods int ="+createLiveRoomParameterStep2Entity.getCloseGoods() |
|
1010 |
+",@isFeedsPublic int = "+createLiveRoomParameterStep2Entity.getIsFeedsPublic()+" \n" |
c19dc5
|
1011 |
+ " declare @myrowcount int \n" |
J |
1012 |
+ " update a set isCloseComment=@isCloseComment,isCloseLike = @isCloseLike,isCloseShare=@isCloseShare, \n" |
|
1013 |
+ " isCloseReplay=@isCloseReplay,isCloseKf=@isCloseKf,isCloseGoods=@isCloseGoods,isFeedsPublic = @isFeedsPublic \n" |
|
1014 |
+ " from t710701 a where a.DocCode = @DocCode \n" |
|
1015 |
+ " select @myrowcount = @@rowcount \n" |
|
1016 |
+ " exec p710701Save @DocCode = @DocCode \n" |
|
1017 |
+ " select @myrowcount \n"; |
|
1018 |
try { |
a92f52
|
1019 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
c19dc5
|
1020 |
|
J |
1021 |
}catch(DataAccessException e){ |
|
1022 |
if (e instanceof EmptyResultDataAccessException) { |
|
1023 |
return null ; |
|
1024 |
} else { |
|
1025 |
throw e ; |
|
1026 |
} |
|
1027 |
}catch(Exception e){ |
|
1028 |
throw e ; |
|
1029 |
} |
|
1030 |
} |
|
1031 |
|
|
1032 |
@Override |
|
1033 |
public Integer createRoomStep3(CreateLiveRoomParameterStep3Entity createLiveRoomParameterStep3Entity) { |
a92f52
|
1034 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
c19dc5
|
1035 |
String sql = " set nocount on ; \n" |
a92f52
|
1036 |
+ " declare @DocCode varchar(20) = "+GridUtils.prossSqlParm(createLiveRoomParameterStep3Entity.getDocCode()) |
J |
1037 |
+",@StartTime DateTime = "+GridUtils.prossSqlParm(createLiveRoomParameterStep3Entity.getStartDateTime()==null?null:sdf.format(createLiveRoomParameterStep3Entity.getStartDateTime())) |
|
1038 |
+",@EndTime datetime = "+GridUtils.prossSqlParm(createLiveRoomParameterStep3Entity.getEndDateTime()==null?null:sdf.format(createLiveRoomParameterStep3Entity.getEndDateTime())) +" \n" |
c19dc5
|
1039 |
+ " declare @myrowcount int \n" |
J |
1040 |
+ " update a set StartTime = @StartTime,EndTime = @EndTime \n" |
|
1041 |
+ " from t710701 a where a.DocCode = @DocCode \n" |
|
1042 |
+ " select @myrowcount = @@rowcount \n" |
|
1043 |
+ " exec p710701Save @DocCode = @DocCode \n" |
|
1044 |
+ " select @myrowcount \n"; |
|
1045 |
try { |
a92f52
|
1046 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
c19dc5
|
1047 |
|
J |
1048 |
}catch(DataAccessException e){ |
|
1049 |
if (e instanceof EmptyResultDataAccessException) { |
|
1050 |
return null ; |
|
1051 |
} else { |
|
1052 |
throw e ; |
|
1053 |
} |
|
1054 |
}catch(Exception e){ |
|
1055 |
throw e ; |
|
1056 |
} |
|
1057 |
} |
|
1058 |
|
|
1059 |
@Override |
a6a76f
|
1060 |
public Integer saveAttachment(String docCode,String fieldId,String unid,Integer seq) { |
F |
1061 |
String sql = " set nocount on ; \n" |
a92f52
|
1062 |
+ " declare @DocCode varchar(20) = "+GridUtils.prossSqlParm(docCode)+",@FieldId varchar(50) = "+GridUtils.prossSqlParm(fieldId) |
J |
1063 |
+",@Unid varchar(50) = "+GridUtils.prossSqlParm(unid)+",@Seq int = "+seq+" \n" |
a6a76f
|
1064 |
+ " declare @isFound int = 0 \n" |
F |
1065 |
+ " if isnull(@FieldId,'') = 'coverImg' \n" |
|
1066 |
+ " begin \n" |
|
1067 |
+ " update a set CoverImgUnid = isnull(@Unid,'') + ';' + cast(@Seq as varchar(20)) from t710701 a where a.DocCode = @DocCode \n" |
|
1068 |
+ " set @isFound = @@rowcount \n" |
|
1069 |
+ " end \n" |
|
1070 |
+ " if isnull(@FieldId,'') = 'shareImg' \n" |
|
1071 |
+ " begin \n" |
|
1072 |
+ " update a set ShareImgUnid = isnull(@Unid,'') + ';' + cast(@Seq as varchar(20)) from t710701 a where a.DocCode = @DocCode \n" |
|
1073 |
+ " set @isFound = @@rowcount \n" |
|
1074 |
+ " end \n" |
|
1075 |
+ " if isnull(@FieldId,'') = 'feedsImg' \n" |
|
1076 |
+ " begin \n" |
|
1077 |
+ " update a set FeedsImgUnid = isnull(@Unid,'') + ';' + cast(@Seq as varchar(20)) from t710701 a where a.DocCode = @DocCode \n" |
|
1078 |
+ " set @isFound = @@rowcount \n" |
|
1079 |
+ " end \n" |
|
1080 |
+ " if isnull(@FieldId,'') = 'bannerPhoto' \n" |
|
1081 |
+ " begin \n" |
|
1082 |
+ " update a set BannerPhoto = isnull(@Unid,'') + ';' + cast(@Seq as varchar(20)) from t710701 a where a.DocCode = @DocCode \n" |
|
1083 |
+ " set @isFound = @@rowcount \n" |
|
1084 |
+ " end \n" |
|
1085 |
+ " select isnull(@isFound,0) \n" ; |
|
1086 |
try { |
a92f52
|
1087 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
a6a76f
|
1088 |
} catch(DataAccessException e){ |
F |
1089 |
if (e instanceof EmptyResultDataAccessException) { |
|
1090 |
return null ; |
|
1091 |
} else { |
|
1092 |
throw e ; |
|
1093 |
} |
|
1094 |
}catch(Exception e){ |
|
1095 |
throw e ; |
|
1096 |
} |
|
1097 |
} |
|
1098 |
|
|
1099 |
@Override |
|
1100 |
public LiveRoomEntity getLiveRoom(Integer roomId) { |
|
1101 |
String sql = " set nocount on ; \n" |
a92f52
|
1102 |
+ " declare @RoomId int = "+roomId+" \n" |
a6a76f
|
1103 |
+ " select RoomId,RoomName,CoverImg,LiveStatus,StartTime,EndTime,AnchorName,AnchorImg,ShopCcCode, \n" |
F |
1104 |
+ " DATEDIFF(SECOND,getdate(), a.StartTime) as LiveBalanceSecond, \n" |
f161ef
|
1105 |
+ " a.isShowBannerPhotoOnHomePage ,a.BannerPhoto,a.ShareImg,a.CoverImgUnid,a.CoverImgUnidUrl,a.ShareImgUnid,a.ShareImgUnidUrl,a.AnchorImgUnid,a.AnchorImgUnidUrl, \n" |
J |
1106 |
+ " a.Type,a.AnchorWechat,a.isFeedsPublic,a.FeedsImgUnid,a.FeedsImgUnidUrl,a.ScreenType,a.isCloseLike,a.isCloseGoods,a.isCloseComment,\n" |
c02895
|
1107 |
+ " a.isCloseReplay,a.isCloseShare,a.isCloseKf, \n" |
J |
1108 |
+ " a.DocCode,a.DocDate,a.FormId,a.RoomQrCodeUrl,a.RoomQrCodeUrlUnid \n" |
a6a76f
|
1109 |
+ " from t710701 a \n" |
F |
1110 |
+ " where a.RoomId = @RoomId \n"; |
|
1111 |
LiveRoomEntity liveRoomEntity = new LiveRoomEntity() ; |
|
1112 |
try { |
a92f52
|
1113 |
Map<String,Object> map = this.jdbcTemplate.queryForMap(sql) ; |
a6a76f
|
1114 |
if (map != null) { |
F |
1115 |
RoomInfo roomInfo = getRoomInfo(map, liveRoomEntity) ; |
|
1116 |
List<RoomInfo> roomInfoList = new ArrayList<RoomInfo>(1) ; |
|
1117 |
roomInfoList.add(roomInfo); |
c02895
|
1118 |
liveRoomEntity.setRoomInfo(roomInfoList); |
J |
1119 |
|
a6a76f
|
1120 |
return liveRoomEntity; |
F |
1121 |
} |
|
1122 |
}catch(DataAccessException e){ |
|
1123 |
if (e instanceof EmptyResultDataAccessException) { |
|
1124 |
return null ; |
|
1125 |
} else { |
|
1126 |
throw e ; |
|
1127 |
} |
|
1128 |
}catch(Exception e){ |
|
1129 |
throw e ; |
|
1130 |
} |
|
1131 |
return liveRoomEntity; |
|
1132 |
} |
|
1133 |
|
|
1134 |
@Override |
|
1135 |
public Integer saveRoomIdByRoomDocCode(String docCode,Integer roomId,String qrCodeUrl,String qrCodeUrlUnid) { |
|
1136 |
String sql = " set nocount on ; \n" |
a92f52
|
1137 |
+ " declare @DocCode varchar(20) = "+GridUtils.prossSqlParm(docCode)+" ,@RoomId int = "+roomId |
J |
1138 |
+",@QrCodeUrl varchar(500)="+GridUtils.prossSqlParm(qrCodeUrl)+" ,@QrCodeUrlUnid varchar(50) = "+GridUtils.prossSqlParm(qrCodeUrlUnid)+" \n" |
a6a76f
|
1139 |
+ " update a set RoomId = @RoomId,QrCodeUrl = @QrCodeUrl,QrCodeUrlUnid = @QrCodeUrlUnid \n" |
F |
1140 |
+ " from t710701 a \n" |
|
1141 |
+ " where a.DocCode = @DocCode \n" |
|
1142 |
+ " select @@rowcount \n"; |
|
1143 |
try { |
a92f52
|
1144 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
a6a76f
|
1145 |
}catch(DataAccessException e){ |
F |
1146 |
if (e instanceof EmptyResultDataAccessException) { |
|
1147 |
return null ; |
|
1148 |
} else { |
|
1149 |
throw e ; |
|
1150 |
} |
|
1151 |
}catch(Exception e){ |
|
1152 |
throw e ; |
|
1153 |
} |
|
1154 |
} |
|
1155 |
|
|
1156 |
@Override |
|
1157 |
public LiveRoomEntity getLiveRoom(String docCode) { |
|
1158 |
String sql = " set nocount on ; \n" |
a92f52
|
1159 |
+ " declare @DocCode varchar(20) = "+GridUtils.prossSqlParm(docCode)+" \n" |
a6a76f
|
1160 |
+ " select a.RoomId,a.RoomName,a.CoverImg,a.LiveStatus,a.StartTime,a.EndTime,\n" |
F |
1161 |
+ " a.AnchorWechat,a.AnchorName,a.AnchorImg,a.AnchorImgUnid,a.AnchorImgUnidUrl,a.SubAnchorWechat,a.ShopCcCode, \n" |
|
1162 |
+ " DATEDIFF(SECOND,getdate(), a.StartTime) as LiveBalanceSecond, \n" |
f161ef
|
1163 |
+ " a.isShowBannerPhotoOnHomePage ,a.BannerPhoto,a.BannerPhotoUrl,a.ShareImg,a.CoverImgUnid,a.CoverImgUnidUrl,a.ShareImgUnid,a.ShareImgUnidUrl, \n" |
J |
1164 |
+ " a.Type,a.isFeedsPublic,a.FeedsImgUnid,a.FeedsImgUnidUrl,a.ScreenType,a.isCloseLike,a.isCloseGoods,a.isCloseComment,\n" |
a6a76f
|
1165 |
+ " a.isCloseReplay,a.isCloseShare,a.isCloseKf,a.QrCodeUrl,a.QrCodeUrlUnid, \n" |
6e0012
|
1166 |
+ " a.DocCode,a.DocDate,a.FormId,a.SubscribeTimes \n" |
a6a76f
|
1167 |
+ " from t710701 a \n" |
F |
1168 |
+ " where a.DocCode = @DocCode \n"; |
|
1169 |
LiveRoomEntity liveRoomEntity = new LiveRoomEntity() ; |
|
1170 |
try { |
a92f52
|
1171 |
Map<String,Object> map = this.jdbcTemplate.queryForMap(sql) ; |
a6a76f
|
1172 |
if (map != null) { |
F |
1173 |
RoomInfo roomInfo = getRoomInfo(map, liveRoomEntity) ; |
|
1174 |
List<RoomInfo> roomInfoList = new ArrayList<RoomInfo>(1) ; |
|
1175 |
roomInfoList.add(roomInfo); |
|
1176 |
liveRoomEntity.setRoomInfo(roomInfoList); |
|
1177 |
return liveRoomEntity; |
|
1178 |
} |
|
1179 |
}catch(DataAccessException e){ |
|
1180 |
if (e instanceof EmptyResultDataAccessException) { |
|
1181 |
return null ; |
|
1182 |
} else { |
|
1183 |
throw e ; |
|
1184 |
} |
|
1185 |
}catch(Exception e){ |
|
1186 |
throw e ; |
|
1187 |
} |
|
1188 |
return liveRoomEntity; |
|
1189 |
} |
|
1190 |
|
|
1191 |
@Override |
|
1192 |
public LiveRoomEntity getLiveRoomBannerPhotoList(String shopCcCode) { |
|
1193 |
String sql = " set nocount on ; \n" |
a92f52
|
1194 |
+ " declare @ShopCcCode varchar(50) = "+GridUtils.prossSqlParm(shopCcCode)+" \n" |
a6a76f
|
1195 |
|
F |
1196 |
+ " select a.RoomId,a.RoomName,a.CoverImg,a.LiveStatus,a.StartTime,a.EndTime,\n" |
|
1197 |
+ " a.AnchorWechat,a.AnchorName,a.AnchorImg,a.AnchorImgUnid,a.AnchorImgUnidUrl,a.SubAnchorWechat,a.ShopCcCode, \n" |
|
1198 |
+ " DATEDIFF(SECOND,getdate(), a.StartTime) as LiveBalanceSecond, \n" |
9fabeb
|
1199 |
+ " a.isShowBannerPhotoOnHomePage ,a.BannerPhoto,a.BannerPhotoUrl,a.CoverImg,a.CoverImgUnid,a.CoverImgUnidUrl,a.ShareImg,a.ShareImgUnid,a.ShareImgUnidUrl, \n" |
f161ef
|
1200 |
+ " a.Type,a.isFeedsPublic,a.FeedsImgUnid,a.FeedsImgUnidUrl,a.ScreenType,a.isCloseLike,a.isCloseGoods,a.isCloseComment,\n" |
a6a76f
|
1201 |
+ " a.isCloseReplay,a.isCloseShare,a.isCloseKf,a.QrCodeUrl,QrCodeUrlUnid, \n" |
F |
1202 |
+ " a.DocCode,a.DocDate,a.FormId,a.EnterCode,a.EnterName,a.EnterDate \n" |
|
1203 |
+ " from t710701 a \n" |
|
1204 |
+ " where (isnull(@ShopCcCode,'') = '' or a.ShopCcCode = @ShopCcCode) \n" |
|
1205 |
+ " and isnull(a.RoomId,0) <> 0 \n" |
|
1206 |
+ " order by a.LiveStatus asc,a.StartTime desc,a.EndTime desc \n" ; |
|
1207 |
LiveRoomEntity liveRoomEntity = new LiveRoomEntity() ; |
|
1208 |
try { |
a92f52
|
1209 |
List<Map<String,Object>> list = this.jdbcTemplate.queryForList(sql) ; |
a6a76f
|
1210 |
if (list != null) { |
F |
1211 |
List<RoomInfo> roomInfoList = new ArrayList<RoomInfo>(list.size()) ; |
|
1212 |
for (int i = 0; i < list.size() ; i ++) { |
|
1213 |
roomInfoList.add(getRoomInfo(list.get(i), liveRoomEntity) ) ; |
|
1214 |
} |
|
1215 |
liveRoomEntity.setTotal(list.size()); |
|
1216 |
liveRoomEntity.setRoomInfo(roomInfoList); |
|
1217 |
} |
|
1218 |
}catch(DataAccessException e){ |
|
1219 |
if (e instanceof EmptyResultDataAccessException) { |
|
1220 |
return null ; |
|
1221 |
} else { |
|
1222 |
throw e ; |
|
1223 |
} |
|
1224 |
}catch(Exception e){ |
|
1225 |
throw e ; |
|
1226 |
} |
|
1227 |
return liveRoomEntity; |
|
1228 |
} |
|
1229 |
|
|
1230 |
@Override |
|
1231 |
public LiveRoomEntity getLiveRoomListForMe(Integer roomId,String shopCcCode,String userCode,String docCode) { |
|
1232 |
String sql = " set nocount on ; \n" |
a92f52
|
1233 |
+ " declare @RoomId int = "+roomId+",@ShopCcCode varchar(50) = "+GridUtils.prossSqlParm(shopCcCode)+" \n" |
J |
1234 |
+ " declare @UserCode varchar(50) = "+GridUtils.prossSqlParm(userCode)+",@DocCode varchar(20) = "+GridUtils.prossSqlParm(docCode)+" \n" |
a6a76f
|
1235 |
|
F |
1236 |
+ " declare @DefaultBrand varchar(50),@isStartupLeagueShopCcCode int \n" |
|
1237 |
//+ " select @isStartupLeagueShopCcCode = a.isStartupLeagueShopCcCode from t714001 a \n" |
|
1238 |
|
|
1239 |
+ " select top 1 @DefaultBrand = DefaultBrand \n" |
|
1240 |
+ " from _sys_LoginUser where UserCode = @UserCode \n" |
|
1241 |
|
|
1242 |
+ " select a.RoomId,a.RoomName,a.CoverImg,a.LiveStatus,a.StartTime,a.EndTime,\n" |
|
1243 |
+ " a.AnchorWechat,a.AnchorName,a.AnchorImg,a.AnchorImgUnid,a.AnchorImgUnidUrl,a.SubAnchorWechat,a.ShopCcCode, \n" |
|
1244 |
+ " DATEDIFF(SECOND,getdate(), a.StartTime) as LiveBalanceSecond, \n" |
64db07
|
1245 |
+ " a.isShowBannerPhotoOnHomePage ,a.BannerPhoto,a.BannerPhotoUrl,a.ShareImg,a.CoverImgUnid,a.CoverImgUnidUrl,a.ShareImgUnid,a.ShareImgUnidUrl, \n" |
J |
1246 |
+ " a.Type,a.isFeedsPublic,a.FeedsImgUnid,a.FeedsImgUnidUrl,a.ScreenType,a.isCloseLike,a.isCloseGoods,a.isCloseComment,\n" |
a6a76f
|
1247 |
+ " a.isCloseReplay,a.isCloseShare,a.isCloseKf,a.QrCodeUrl,a.QrCodeUrlUnid, \n" |
F |
1248 |
+ " a.DocCode,a.DocDate,a.FormId,a.EnterCode,a.EnterName,a.EnterDate \n" |
|
1249 |
+ " from t710701 a \n" |
|
1250 |
+ " where (isnull(@ShopCcCode,'') = '' or a.ShopCcCode = @ShopCcCode) \n" |
|
1251 |
+ " and (isnull(@RoomId,0) = 0 or a.RoomId = @RoomId ) \n" |
|
1252 |
+ " and (isnull(@DocCode,'') = '' or a.DocCode = @DocCode ) \n" |
|
1253 |
|
|
1254 |
+ " and ((isnull(@DefaultBrand,'') = '' and isnull(a.Brand,'')= '') or (isnull(@DefaultBrand,'') <> '' and a.Brand = @DefaultBrand or a.EnterCode = @UserCode)) \n" |
|
1255 |
+ " order by a.LiveStatus asc,a.StartTime desc,a.EndTime desc \n" ; |
|
1256 |
LiveRoomEntity liveRoomEntity = new LiveRoomEntity() ; |
|
1257 |
try { |
a92f52
|
1258 |
List<Map<String,Object>> list = this.jdbcTemplate.queryForList(sql) ; |
a6a76f
|
1259 |
if (list != null) { |
F |
1260 |
List<RoomInfo> roomInfoList = new ArrayList<RoomInfo>(list.size()) ; |
|
1261 |
for (int i = 0; i < list.size() ; i ++) { |
|
1262 |
roomInfoList.add(getRoomInfo(list.get(i), liveRoomEntity) ) ; |
|
1263 |
} |
|
1264 |
liveRoomEntity.setTotal(list.size()); |
|
1265 |
liveRoomEntity.setRoomInfo(roomInfoList); |
|
1266 |
} |
|
1267 |
}catch(DataAccessException e){ |
|
1268 |
if (e instanceof EmptyResultDataAccessException) { |
|
1269 |
return null ; |
|
1270 |
} else { |
|
1271 |
throw e ; |
|
1272 |
} |
|
1273 |
}catch(Exception e){ |
|
1274 |
throw e ; |
|
1275 |
} |
|
1276 |
return liveRoomEntity; |
|
1277 |
} |
|
1278 |
|
|
1279 |
@Override |
64db07
|
1280 |
public LiveRoomEntity getLiveRoomListForOpenId(String openId) { |
J |
1281 |
String sql = " set nocount on ; \n" |
a92f52
|
1282 |
+ " declare @OpenId varchar(200) = "+GridUtils.prossSqlParm(openId)+" \n" |
64db07
|
1283 |
+ " select a.RoomId,a.RoomName,a.CoverImg,a.LiveStatus,a.StartTime,a.EndTime,\n" |
J |
1284 |
+ " a.AnchorWechat,a.AnchorName,a.AnchorImg,a.AnchorImgUnid,a.AnchorImgUnidUrl,a.SubAnchorWechat,a.ShopCcCode, \n" |
|
1285 |
+ " DATEDIFF(SECOND,getdate(), a.StartTime) as LiveBalanceSecond, \n" |
9fabeb
|
1286 |
+ " a.isShowBannerPhotoOnHomePage ,a.BannerPhoto,a.BannerPhotoUrl,a.CoverImg,a.CoverImgUnid,a.CoverImgUnidUrl,a.ShareImg,a.ShareImgUnid,a.ShareImgUnidUrl, \n" |
64db07
|
1287 |
+ " a.Type,a.isFeedsPublic,a.FeedsImgUnid,a.FeedsImgUnidUrl,a.ScreenType,a.isCloseLike,a.isCloseGoods,a.isCloseComment,\n" |
J |
1288 |
+ " a.isCloseReplay,a.isCloseShare,a.isCloseKf,a.QrCodeUrl,a.QrCodeUrlUnid, \n" |
6e0012
|
1289 |
+ " a.DocCode,a.DocDate,a.FormId,a.EnterCode,a.EnterName,a.EnterDate,a.SubscribeTimes \n" |
64db07
|
1290 |
+ " from t710701 a \n" |
J |
1291 |
+ " where a.OpenId = @OpenId \n" |
b8896c
|
1292 |
+ " order by a.EnterDate desc,a.StartTime desc,a.EndTime desc \n" ; |
64db07
|
1293 |
LiveRoomEntity liveRoomEntity = new LiveRoomEntity() ; |
J |
1294 |
try { |
a92f52
|
1295 |
List<Map<String,Object>> list = this.jdbcTemplate.queryForList(sql) ; |
64db07
|
1296 |
if (list != null) { |
J |
1297 |
List<RoomInfo> roomInfoList = new ArrayList<RoomInfo>(list.size()) ; |
|
1298 |
for (int i = 0; i < list.size() ; i ++) { |
|
1299 |
roomInfoList.add(getRoomInfo(list.get(i), liveRoomEntity) ) ; |
|
1300 |
} |
|
1301 |
liveRoomEntity.setTotal(list.size()); |
|
1302 |
liveRoomEntity.setRoomInfo(roomInfoList); |
|
1303 |
} |
|
1304 |
}catch(DataAccessException e){ |
|
1305 |
if (e instanceof EmptyResultDataAccessException) { |
|
1306 |
return null ; |
|
1307 |
} else { |
|
1308 |
throw e ; |
|
1309 |
} |
|
1310 |
}catch(Exception e){ |
|
1311 |
throw e ; |
|
1312 |
} |
|
1313 |
return liveRoomEntity; |
|
1314 |
} |
|
1315 |
|
|
1316 |
|
|
1317 |
@Override |
a6a76f
|
1318 |
public LiveRoomEntity getLiveRoomList(Integer roomId,String shopCcCode,boolean isShowBannerPhotoOnHomePage, |
F |
1319 |
boolean isShowOwnerLiveRoom,String userCode,String docCode) { |
|
1320 |
String sql = " set nocount on ; \n" |
a92f52
|
1321 |
+ " declare @RoomId int = "+roomId+",@ShopCcCode varchar(50) = "+GridUtils.prossSqlParm(shopCcCode)+" ,@isShowBannerPhotoOnHomePage int = "+(isShowBannerPhotoOnHomePage?1:0) +" \n" |
J |
1322 |
+ " declare @isShowOwnerLiveRoom int = "+(isShowOwnerLiveRoom?1:0)+", @UserCode varchar(50) = "+GridUtils.prossSqlParm(userCode)+",@DocCode varchar(20) = "+GridUtils.prossSqlParm(docCode)+" \n" |
a6a76f
|
1323 |
|
F |
1324 |
+ " declare @DefaultBrand varchar(50),@isStartupLeagueShopCcCode int \n" |
|
1325 |
//+ " select @isStartupLeagueShopCcCode = a.isStartupLeagueShopCcCode from t714001 a \n" |
|
1326 |
|
|
1327 |
+ " select top 1 @DefaultBrand = DefaultBrand \n" |
|
1328 |
+ " from _sys_LoginUser where UserCode = @UserCode \n" |
|
1329 |
+ " select a.RoomId,a.RoomName,a.CoverImg,a.LiveStatus,a.StartTime,a.EndTime,\n" |
|
1330 |
+ " a.AnchorWechat,a.AnchorName,a.AnchorImg,a.AnchorImgUnid,a.AnchorImgUnidUrl,a.SubAnchorWechat,a.ShopCcCode, \n" |
|
1331 |
+ " DATEDIFF(SECOND,getdate(), a.StartTime) as LiveBalanceSecond, \n" |
64db07
|
1332 |
+ " a.isShowBannerPhotoOnHomePage ,a.BannerPhoto,a.BannerPhotoUrl,a.ShareImg,a.CoverImgUnid,a.CoverImgUnidUrl,a.ShareImgUnid,a.ShareImgUnidUrl, \n" |
J |
1333 |
+ " a.Type,a.isFeedsPublic,a.FeedsImgUnid,a.FeedsImgUnidUrl,a.ScreenType,a.isCloseLike,a.isCloseGoods,a.isCloseComment,\n" |
|
1334 |
+ " a.isCloseReplay,a.isCloseShare,a.isCloseKf,a.QrCodeUrl,a.QrCodeUrlUnid, \n" |
a6a76f
|
1335 |
+ " a.DocCode,a.DocDate,a.FormId,a.EnterCode,a.EnterName,a.EnterDate \n" |
F |
1336 |
+ " from t710701 a \n" |
|
1337 |
+ " where (isnull(@ShopCcCode,'') = '' or a.ShopCcCode = @ShopCcCode) \n" |
|
1338 |
+ " and (isnull(@RoomId,0) = 0 or a.RoomId = @RoomId ) \n" |
|
1339 |
+ " and (isnull(@DocCode,'') = '' or a.DocCode = @DocCode ) \n" |
|
1340 |
+ " and (isnull(@isShowBannerPhotoOnHomePage,0) = 0 or a.isShowBannerPhotoOnHomePage = @isShowBannerPhotoOnHomePage ) \n" |
|
1341 |
+ " and (isnull(@isShowOwnerLiveRoom,0) = 0 or (isnull(@isShowOwnerLiveRoom,0) = 1 and (isnull(@DefaultBrand,'') = '' and isnull(a.Brand,'')= '' or isnull(@DefaultBrand,'') <> '' and a.Brand = @DefaultBrand or a.EnterCode = @UserCode) )) \n" |
|
1342 |
+ " order by a.LiveStatus asc,a.StartTime desc,a.EndTime desc \n" ; |
|
1343 |
LiveRoomEntity liveRoomEntity = new LiveRoomEntity() ; |
|
1344 |
try { |
a92f52
|
1345 |
List<Map<String,Object>> list = this.jdbcTemplate.queryForList(sql) ; |
a6a76f
|
1346 |
if (list != null) { |
F |
1347 |
List<RoomInfo> roomInfoList = new ArrayList<RoomInfo>(list.size()) ; |
|
1348 |
for (int i = 0; i < list.size() ; i ++) { |
|
1349 |
roomInfoList.add(getRoomInfo(list.get(i), liveRoomEntity) ) ; |
|
1350 |
} |
|
1351 |
liveRoomEntity.setTotal(list.size()); |
|
1352 |
liveRoomEntity.setRoomInfo(roomInfoList); |
|
1353 |
} |
|
1354 |
}catch(DataAccessException e){ |
|
1355 |
if (e instanceof EmptyResultDataAccessException) { |
|
1356 |
return null ; |
|
1357 |
} else { |
|
1358 |
throw e ; |
|
1359 |
} |
|
1360 |
}catch(Exception e){ |
|
1361 |
throw e ; |
|
1362 |
} |
|
1363 |
return liveRoomEntity; |
|
1364 |
} |
|
1365 |
|
|
1366 |
private RoomInfo getRoomInfo(Map<String , Object> map,LiveRoomEntity liveRoomEntity) { |
|
1367 |
if (map==null ) return null ; |
|
1368 |
RoomInfo roomInfo = liveRoomEntity.new RoomInfo() ; |
|
1369 |
roomInfo.setName(map.get("RoomName") == null ? "" : (String)map.get("RoomName")) ; |
bff6b6
|
1370 |
roomInfo.setId(map.get("RoomId") == null ? null : (Integer)map.get("RoomId")) ; |
a6a76f
|
1371 |
roomInfo.setCoverImg(map.get("CoverImg") == null ? "" : (String)map.get("CoverImg")) ; |
F |
1372 |
roomInfo.setCoverImgUnid(map.get("CoverImgUnid") == null ? "" : (String)map.get("CoverImgUnid")) ; |
64db07
|
1373 |
roomInfo.setCoverImgUnidUrl(map.get("CoverImgUnidUrl") == null ? "" : (String)map.get("CoverImgUnidUrl")) ; |
a6a76f
|
1374 |
roomInfo.setLiveStatus(map.get("LiveStatus") == null ? null : (Integer)map.get("LiveStatus")) ; |
F |
1375 |
roomInfo.setStartDateTime(map.get("StartTime") == null ? null : (Date)map.get("StartTime")) ; |
|
1376 |
roomInfo.setEndDateTime(map.get("EndTime") == null ? null: (Date)map.get("EndTime")) ; |
|
1377 |
roomInfo.setStartTime(roomInfo.getStartDateTime()!=null? roomInfo.getStartDateTime().getTime()/1000:null) ; |
|
1378 |
roomInfo.setEndTime(roomInfo.getEndDateTime()!=null? roomInfo.getEndDateTime().getTime()/1000:null) ; |
|
1379 |
roomInfo.setAnchorName(map.get("AnchorName") == null ? "" : (String)map.get("AnchorName")) ; |
|
1380 |
roomInfo.setAnchorImg(map.get("AnchorImg") == null ? "" : (String)map.get("AnchorImg")) ; |
|
1381 |
roomInfo.setAnchorImgUnid(map.get("AnchorImgUnid") == null ? "" : (String)map.get("AnchorImgUnid")) ; |
|
1382 |
roomInfo.setAnchorImgUnidUrl(map.get("AnchorImgUnidUrl") == null ? "" : (String)map.get("AnchorImgUnidUrl")) ; |
|
1383 |
roomInfo.setSubAnchorWechat(map.get("SubAnchorWechat") == null ? "" : (String)map.get("SubAnchorWechat")) ; |
|
1384 |
roomInfo.setShareImg(map.get("ShareImg") == null ? "" : (String)map.get("ShareImg")) ; |
|
1385 |
roomInfo.setShareImgUnid(map.get("ShareImgUnid") == null ? "" : (String)map.get("ShareImgUnid")) ; |
64db07
|
1386 |
roomInfo.setShareImgUnidUrl(map.get("ShareImgUnidUrl") == null ? "" : (String)map.get("ShareImgUnidUrl")) ; |
a6a76f
|
1387 |
roomInfo.setShopCcCode(map.get("ShopCcCode") == null ? "" : (String)map.get("ShopCcCode")) ; |
F |
1388 |
roomInfo.setLiveBalanceSecond(map.get("LiveBalanceSecond") == null ? 0 : (Integer)map.get("LiveBalanceSecond")) ; |
|
1389 |
roomInfo.setShowBannerPhotoOnHomePage(map.get("isShowBannerPhotoOnHomePage") != null &&map.get("isShowBannerPhotoOnHomePage").equals(1)?true:false) ; |
|
1390 |
roomInfo.setBannerPhoto(map.get("BannerPhoto") == null ? "" : (String)map.get("BannerPhoto")) ; |
|
1391 |
roomInfo.setBannerPhotoUrl(map.get("BannerPhotoUrl") == null ? "" : (String)map.get("BannerPhotoUrl")) ; |
|
1392 |
roomInfo.setType(map.get("Type") == null ? 0 : (Integer)map.get("Type")) ; |
|
1393 |
roomInfo.setAnchorWechat(map.get("AnchorWechat") == null ? "" : (String)map.get("AnchorWechat")) ; |
1f5ccf
|
1394 |
roomInfo.setIsFeedsPublic(map.get("isFeedsPublic") == null?0:(Integer)map.get("isFeedsPublic")) ; |
a6a76f
|
1395 |
roomInfo.setFeedsImgUnid(map.get("FeedsImgUnid") == null ? "" : (String)map.get("FeedsImgUnid")) ; |
64db07
|
1396 |
roomInfo.setFeedsImgUnidUrl(map.get("FeedsImgUnidUrl") == null ? "" : (String)map.get("FeedsImgUnidUrl")) ; |
a6a76f
|
1397 |
roomInfo.setScreenType(map.get("ScreenType") == null ? 0 : (Integer)map.get("ScreenType")) ; |
bff6b6
|
1398 |
roomInfo.setCloseLike(map.get("isCloseLike") == null?0:(Integer)map.get("isCloseLike")) ; |
J |
1399 |
roomInfo.setCloseGoods(map.get("isCloseGoods") == null?0:(Integer)map.get("isCloseGoods")) ; |
|
1400 |
roomInfo.setCloseComment(map.get("isCloseComment") == null?0:(Integer)map.get("isCloseComment")) ; |
|
1401 |
roomInfo.setCloseReplay(map.get("isCloseReplay") == null?0:(Integer)map.get("isCloseReplay")) ; |
|
1402 |
roomInfo.setCloseShare(map.get("isCloseShare") == null?0:(Integer)map.get("isCloseShare")) ; |
|
1403 |
roomInfo.setCloseKf(map.get("isCloseKf") == null?0:(Integer)map.get("isCloseKf")) ; |
a6a76f
|
1404 |
roomInfo.setQrCodeUrl(map.get("QrCodeUrl") == null?"":(String)map.get("QrCodeUrl")) ; |
F |
1405 |
roomInfo.setQrCodeUrlUnid(map.get("QrCodeUrlUnid") == null?"":(String)map.get("QrCodeUrlUnid")) ; |
|
1406 |
roomInfo.setDocCode(map.get("DocCode") == null?"":(String)map.get("DocCode")) ; |
|
1407 |
roomInfo.setDocDate(map.get("DocDate") == null?null:(Date)map.get("DocDate")) ; |
|
1408 |
roomInfo.setFormId(map.get("FormId") == null?null:(Integer)map.get("FormId")) ; |
|
1409 |
roomInfo.setEnterCode(map.get("EnterCode") == null?null:(String)map.get("EnterCode")) ; |
|
1410 |
roomInfo.setEnterName(map.get("EnterName") == null?null:(String)map.get("EnterName")) ; |
|
1411 |
roomInfo.setEnterDate(map.get("EnterDate") == null?null:(Date)map.get("EnterDate")) ; |
f161ef
|
1412 |
roomInfo.setLiveStatus(map.get("LiveStatus") == null?null:(Integer)map.get("LiveStatus")) ; |
6e0012
|
1413 |
roomInfo.setSubscribeTimes(map.get("SubscribeTimes") == null?0:(Integer)map.get("SubscribeTimes")) ; |
c02895
|
1414 |
roomInfo.setRoomQrCodeUrl(map.get("RoomQrCodeUrl") == null?"":(String)map.get("RoomQrCodeUrl")) ; |
J |
1415 |
roomInfo.setRoomQrCodeUrlUnid(map.get("RoomQrCodeUrlUnid") == null?"":(String)map.get("RoomQrCodeUrlUnid")) ; |
a6a76f
|
1416 |
return roomInfo; |
F |
1417 |
} |
|
1418 |
|
|
1419 |
@Override |
|
1420 |
public LiveReplayVideoEntity getReplayVideo(Integer roomId) { |
|
1421 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
1422 |
String sql = " set nocount on ; \n" |
a92f52
|
1423 |
+ " declare @RoomId int = "+roomId+" \n" |
a6a76f
|
1424 |
+ " select RoomId,CreateTime,ExpireTime,MediaUrl \n" |
F |
1425 |
+ " from t710702 a \n" |
|
1426 |
+ " order by a.CreateTime asc \n" ; |
|
1427 |
LiveReplayVideoEntity liveReplayVideoEntity = new LiveReplayVideoEntity() ; |
|
1428 |
try { |
a92f52
|
1429 |
List<Map<String,Object>> list = this.jdbcTemplate.queryForList(sql) ; |
a6a76f
|
1430 |
if (list != null) { |
F |
1431 |
List<ReplayVideoEntity> liveReplayList = new ArrayList<ReplayVideoEntity>(list.size()) ; |
|
1432 |
for (int i = 0; i < list.size() ; i ++) { |
|
1433 |
Map<String , Object> map = list.get(i); |
|
1434 |
ReplayVideoEntity roomInfo = liveReplayVideoEntity.new ReplayVideoEntity() ; |
|
1435 |
roomInfo.setRoomId(map.get("RoomId") == null ? null : (Integer)map.get("RoomId")) ; |
|
1436 |
roomInfo.setCreateDateTime(map.get("CreateTime") == null ? null : (Date)map.get("CreateTime")) ; |
|
1437 |
roomInfo.setExpireDateTime(map.get("ExpireTime") == null ? null : (Date)map.get("ExpireTime")) ; |
|
1438 |
roomInfo.setCreateTime(roomInfo.getCreateDateTime()!=null?format.format(roomInfo.getCreateDateTime()):"") ; |
|
1439 |
roomInfo.setExpireTime(roomInfo.getExpireDateTime()!=null?format.format(roomInfo.getExpireDateTime()):"") ; |
|
1440 |
|
|
1441 |
roomInfo.setMediaUrl(map.get("MediaUrl") == null ? "" : (String)map.get("MediaUrl")) ; |
|
1442 |
|
|
1443 |
liveReplayList.add(roomInfo) ; |
|
1444 |
} |
|
1445 |
liveReplayVideoEntity.setTotal(list.size()); |
|
1446 |
liveReplayVideoEntity.setLiveReplay(liveReplayList); |
|
1447 |
} |
|
1448 |
}catch(DataAccessException e){ |
|
1449 |
if (e instanceof EmptyResultDataAccessException) { |
|
1450 |
return null ; |
|
1451 |
} else { |
|
1452 |
throw e ; |
|
1453 |
} |
|
1454 |
}catch(Exception e){ |
|
1455 |
throw e ; |
|
1456 |
} |
|
1457 |
return liveReplayVideoEntity; |
|
1458 |
} |
|
1459 |
|
|
1460 |
@Override |
|
1461 |
public Integer saveAddGoods(LiveGoodsEntity goodsEntity) { |
|
1462 |
String sql = " set nocount on ; \n" |
a92f52
|
1463 |
+ " declare @MatCode varchar(50) = "+GridUtils.prossSqlParm(goodsEntity.getMatCode())+",@MatName varchar(80),@Special varchar(80),@CoverImgUrl varchar(500) = "+GridUtils.prossSqlParm(goodsEntity.getCoverImgUrl())+" \n" |
J |
1464 |
+ " declare @PriceType int = "+goodsEntity.getPriceType()+", @Price money = "+goodsEntity.getPrice()+",@Price2 money = "+goodsEntity.getPrice2()+",@URL varchar(200) = "+GridUtils.prossSqlParm(goodsEntity.getUrl())+" \n" |
|
1465 |
+ " declare @AuditId bigint = "+goodsEntity.getAuditId()+",@GoodsId bigint = "+goodsEntity.getGoodsId()+",@AuditStatus int = "+goodsEntity.getAuditStatus()+",@ThirdPartyTag int = "+goodsEntity.getThirdPartyTag()+" \n" |
|
1466 |
+ " declare @DepositDocCode varchar(50) = "+GridUtils.prossSqlParm(goodsEntity.getDepositDocCode())+", @DepositRowId varchar(20) = "+GridUtils.prossSqlParm(goodsEntity.getDepositRowId())+" \n" |
|
1467 |
+ " declare @OpenId varchar(200) = "+GridUtils.prossSqlParm(goodsEntity.getOpenId())+" \n" |
a6a76f
|
1468 |
+ " select @MatName = MatName ,@Special = Special from t110503 a where a.MatCode = @MatCode \n" |
F |
1469 |
+ " if not exists(select 1 from t710703 where MatCode = isnull(@MatCode,'') and DepositDocCode = isnull(@DepositDocCode,'') and DepositRowId = isnull(@DepositRowId,'')) \n" |
|
1470 |
+ " begin \n" |
f161ef
|
1471 |
+ " insert into t710703(GoodsId,MatCode,MatName,Special,CoverImgUrl,PriceType,Price,Price2,URL,AuditId,AuditStatus,ThirdPartyTag,DepositDocCode,DepositRowId,OpenId) \n" |
J |
1472 |
+ " values(@GoodsId,isnull(@MatCode,''),isnull(@MatName,''),isnull(@Special,''),@CoverImgUrl,@PriceType,@Price,@Price2,@URL,@AuditId,@AuditStatus,@ThirdPartyTag,isnull(@DepositDocCode,''),isnull(@DepositRowId,''),@OpenId) \n" |
a6a76f
|
1473 |
+ " end \n" |
F |
1474 |
+ " select @@rowcount \n"; |
|
1475 |
try { |
a92f52
|
1476 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
f161ef
|
1477 |
}catch(DataAccessException e){ |
J |
1478 |
if (e instanceof EmptyResultDataAccessException) { |
|
1479 |
return null ; |
|
1480 |
} else { |
|
1481 |
throw e ; |
|
1482 |
} |
|
1483 |
}catch(Exception e){ |
|
1484 |
throw e ; |
|
1485 |
} |
|
1486 |
} |
|
1487 |
|
|
1488 |
|
|
1489 |
@Override |
|
1490 |
public Integer updateGoodsAuditStatus(LiveGoodsEntity goodsEntity) { |
|
1491 |
String sql = " set nocount on ; \n" |
a92f52
|
1492 |
+ " declare @CoverImgUrl varchar(500) = "+GridUtils.prossSqlParm(goodsEntity.getCoverImgUrl())+" \n" |
J |
1493 |
+ " declare @PriceType int = "+goodsEntity.getPriceType()+", @Price money = "+goodsEntity.getPrice()+",@Price2 money = "+goodsEntity.getPrice2()+",@URL varchar(200) = "+GridUtils.prossSqlParm(goodsEntity.getUrl())+" \n" |
|
1494 |
+ " declare @AuditId bigint = "+goodsEntity.getAuditId()+",@GoodsId bigint = "+goodsEntity.getGoodsId()+",@AuditStatus int = "+goodsEntity.getAuditStatus()+",@ThirdPartyTag int = "+goodsEntity.getThirdPartyTag()+" \n" |
f161ef
|
1495 |
|
J |
1496 |
+ " update a set GoodsId = @GoodsId,CoverImgUrl=@CoverImgUrl,PriceType=@PriceType,Price=@Price,\n" |
|
1497 |
+ " Price2=@Price2,URL=@URL,AuditId=@AuditId,AuditStatus=@AuditStatus,ThirdPartyTag=@ThirdPartyTag \n" |
|
1498 |
+ " from t710703 a where a.GoodsId = @GoodsId \n" |
|
1499 |
+ " select @@rowcount \n"; |
|
1500 |
try { |
a92f52
|
1501 |
Integer ret = this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
a6a76f
|
1502 |
return ret ; |
F |
1503 |
}catch(DataAccessException e){ |
|
1504 |
if (e instanceof EmptyResultDataAccessException) { |
|
1505 |
return null ; |
|
1506 |
} else { |
|
1507 |
throw e ; |
|
1508 |
} |
|
1509 |
}catch(Exception e){ |
|
1510 |
throw e ; |
|
1511 |
} |
|
1512 |
} |
|
1513 |
|
|
1514 |
@Override |
|
1515 |
public Integer saveUpdateGoods(LiveGoodsEntity goodsEntity) { |
|
1516 |
String sql = " set nocount on ; \n" |
a92f52
|
1517 |
+ " declare @MatCode varchar(50) = "+GridUtils.prossSqlParm(goodsEntity.getMatCode())+",@MatName varchar(80),@Special varchar(80),@CoverImgUrl varchar(500) = "+GridUtils.prossSqlParm(goodsEntity.getCoverImgUrl())+" \n" |
J |
1518 |
+ " declare @PriceType int = "+goodsEntity.getPriceType()+", @Price money = "+goodsEntity.getPrice()+",@Price2 money = "+goodsEntity.getPrice2()+",@URL varchar(200) = "+GridUtils.prossSqlParm(goodsEntity.getUrl())+" \n" |
|
1519 |
+ " declare @AuditId bigint = "+goodsEntity.getAuditId()+",@GoodsId bigint = "+goodsEntity.getGoodsId()+",@AuditStatus int = "+goodsEntity.getAuditStatus()+",@ThirdPartyTag int = "+goodsEntity.getThirdPartyTag()+" \n" |
|
1520 |
+ " declare @DepositDocCode varchar(50) = "+GridUtils.prossSqlParm(goodsEntity.getDepositDocCode())+", @DepositRowId varchar(20) = "+GridUtils.prossSqlParm(goodsEntity.getDepositRowId())+" \n" |
|
1521 |
+ " declare @OpenId varchar(200) = "+GridUtils.prossSqlParm(goodsEntity.getOpenId())+" \n" |
a6a76f
|
1522 |
+ " select @MatName = MatName ,@Special = Special from t110503 a where a.MatCode = @MatCode \n" |
F |
1523 |
+ " update a set GoodsId = @GoodsId,CoverImgUrl=@CoverImgUrl,PriceType=@PriceType,Price=@Price,\n" |
|
1524 |
+ " Price2=@Price2,URL=@URL,AuditId=@AuditId,AuditStatus=@AuditStatus,ThirdPartyTag=@ThirdPartyTag \n" |
|
1525 |
+ " from t710703 a where a.GoodsId = @GoodsId \n" |
148438
|
1526 |
+ " if @@rowcount = 0 \n" |
J |
1527 |
+ " begin \n" |
|
1528 |
+ " insert into t710703(GoodsId,MatCode,MatName,Special,CoverImgUrl,PriceType,Price,Price2,URL,AuditId,AuditStatus,ThirdPartyTag,DepositDocCode,DepositRowId,OpenId) \n" |
|
1529 |
+ " values(@GoodsId,isnull(@MatCode,''),isnull(@MatName,''),isnull(@Special,''),@CoverImgUrl,@PriceType,@Price,@Price2,@URL,@AuditId,@AuditStatus,@ThirdPartyTag,isnull(@DepositDocCode,''),isnull(@DepositRowId,''),isnull(@OpenId,'')) \n" |
|
1530 |
+ " end \n" |
a6a76f
|
1531 |
+ " select @@rowcount \n"; |
F |
1532 |
try { |
a92f52
|
1533 |
Integer ret = this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
a6a76f
|
1534 |
return ret ; |
F |
1535 |
}catch(DataAccessException e){ |
|
1536 |
if (e instanceof EmptyResultDataAccessException) { |
|
1537 |
return null ; |
|
1538 |
} else { |
|
1539 |
throw e ; |
|
1540 |
} |
|
1541 |
}catch(Exception e){ |
|
1542 |
throw e ; |
|
1543 |
} |
|
1544 |
} |
|
1545 |
|
|
1546 |
@Override |
|
1547 |
public Integer saveResetGoods(Long goodsId) { |
|
1548 |
String sql = " set nocount on ; \n" |
a92f52
|
1549 |
+ " declare @GoodsId bigint = "+goodsId+" \n" |
a6a76f
|
1550 |
+ " update a set AuditId= null,AuditStatus = 0 \n" |
F |
1551 |
+ " from t710703 a \n" |
|
1552 |
+ " where a.GoodsId = @GoodsId \n" |
|
1553 |
+ " select @@rowcount \n" ; |
|
1554 |
try { |
a92f52
|
1555 |
Integer ret = this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
a6a76f
|
1556 |
return ret ; |
F |
1557 |
}catch(DataAccessException e){ |
|
1558 |
if (e instanceof EmptyResultDataAccessException) { |
|
1559 |
return null ; |
|
1560 |
} else { |
|
1561 |
throw e ; |
|
1562 |
} |
|
1563 |
}catch(Exception e){ |
|
1564 |
throw e ; |
|
1565 |
} |
|
1566 |
} |
|
1567 |
|
|
1568 |
@Override |
|
1569 |
public Integer saveRepostGoods(Long goodsId,Long auditId) { |
|
1570 |
String sql = " set nocount on ; \n" |
a92f52
|
1571 |
+ " declare @GoodsId bigint = "+goodsId+", @AuditId bigint = "+auditId+" \n" |
a6a76f
|
1572 |
+ " update a set AuditId= @AuditId,AuditStatus = 1 \n" //audit_status 0:未审核,1:审核中,2:审核通过,3审核失败 |
F |
1573 |
+ " from t710703 a \n" |
|
1574 |
+ " where a.GoodsId = @GoodsId \n" |
|
1575 |
+ " select @@rowcount \n" ; |
|
1576 |
try { |
a92f52
|
1577 |
Integer ret = this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
a6a76f
|
1578 |
return ret ; |
F |
1579 |
}catch(DataAccessException e){ |
|
1580 |
if (e instanceof EmptyResultDataAccessException) { |
|
1581 |
return null ; |
|
1582 |
} else { |
|
1583 |
throw e ; |
|
1584 |
} |
|
1585 |
}catch(Exception e){ |
|
1586 |
throw e ; |
|
1587 |
} |
|
1588 |
} |
|
1589 |
|
|
1590 |
@Override |
|
1591 |
public Integer saveDeleteGoods(Long goodsId) { |
|
1592 |
String sql = " set nocount on ; \n" |
a92f52
|
1593 |
+ " declare @GoodsId bigint = "+goodsId+" \n" |
a6a76f
|
1594 |
+ " delete from t710703 where GoodsId = @GoodsId \n" |
F |
1595 |
+ " select @@rowcount \n" ; |
|
1596 |
try { |
a92f52
|
1597 |
Integer ret = this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
a6a76f
|
1598 |
return ret ; |
F |
1599 |
}catch(DataAccessException e){ |
|
1600 |
if (e instanceof EmptyResultDataAccessException) { |
|
1601 |
return null ; |
|
1602 |
} else { |
|
1603 |
throw e ; |
|
1604 |
} |
|
1605 |
}catch(Exception e){ |
|
1606 |
throw e ; |
|
1607 |
} |
|
1608 |
} |
|
1609 |
|
6b10f8
|
1610 |
|
J |
1611 |
|
|
1612 |
@Override |
|
1613 |
public List<LiveGoodsEntity> getGoodsListByExpiredDays(Integer expiredDays) { |
|
1614 |
String sql = " set nocount on \n" |
a92f52
|
1615 |
+ " declare @now datetime = getdate(),@ExpiredDays int = "+expiredDays+" \n" |
6b10f8
|
1616 |
+ " select a.GoodsId,a.MatCode,a.MatName,a.Special,a.CoverImgUrl,\n" |
J |
1617 |
+ " a.PriceType,a.Price,a.Price2,a.URL,a.AuditId,a.AuditStatus,a.ThirdPartyTag, \n" |
|
1618 |
+ " a.DepositDocCode,a.DepositRowId, \n" |
|
1619 |
+ " case when exists(select 1 from t710704 g where a.GoodsId = g.GoodsId) then 1 else 0 end as isAddedToRoom, \n" |
|
1620 |
+ " b.DocCode,b.OriginalPrice,b.SalesPrice,b.Title ,b.CoverImage,b.CoverImageUrl,b.FormId,\n" |
|
1621 |
+ " b.EffectiveStartDate,b.EffectiveEndDate,b.Status as PanicBuyingStatus,b.VisiteTimes,b.SharedTimes,b.OrderTimes \n" |
|
1622 |
+ " from t710703 a \n" |
|
1623 |
+ " join t710802H b on a.MatCode = b.DocCode \n" |
|
1624 |
+ " where DATEDIFF(day,b.EffectiveEndDate,@now) >= @ExpiredDays and b.Status = 3 \n" |
|
1625 |
+ " order by a.MatName asc \n" ; |
|
1626 |
try { |
a92f52
|
1627 |
List<Map<String, Object>> list = this.jdbcTemplate.queryForList(sql) ; |
6b10f8
|
1628 |
List<LiveGoodsEntity> liveGoodsEntities = new ArrayList<LiveGoodsEntity>(); |
J |
1629 |
for (int i = 0; list != null&& i < list.size(); i++) { |
|
1630 |
liveGoodsEntities.add(getGoodsEntity(list.get(i))); |
|
1631 |
} |
|
1632 |
return liveGoodsEntities ; |
|
1633 |
}catch(DataAccessException e ) { |
|
1634 |
if (e instanceof EmptyResultDataAccessException){ |
|
1635 |
return null ; |
|
1636 |
}else { |
|
1637 |
throw e ; |
|
1638 |
} |
|
1639 |
}catch(Exception e){ |
|
1640 |
e.printStackTrace(); |
|
1641 |
throw e; |
|
1642 |
} |
|
1643 |
|
|
1644 |
} |
|
1645 |
|
a6a76f
|
1646 |
@Override |
b326b8
|
1647 |
public List<LiveGoodsEntity> getGoodsListForMe(String openId) { |
J |
1648 |
String sql = " set nocount on ; \n" |
a92f52
|
1649 |
+ " declare @OpenId varchar(200) = "+GridUtils.prossSqlParm(openId)+" \n" |
b326b8
|
1650 |
+ " select a.GoodsId,a.MatCode,a.MatName,a.Special,a.CoverImgUrl,\n" |
J |
1651 |
+ " a.PriceType,a.Price,a.Price2,a.URL,a.AuditId,a.AuditStatus,a.ThirdPartyTag, \n" |
|
1652 |
+ " a.DepositDocCode,a.DepositRowId, \n" |
f161ef
|
1653 |
+ " case when exists(select 1 from t710704 g where a.GoodsId = g.GoodsId) then 1 else 0 end as isAddedToRoom, \n" |
4f0006
|
1654 |
+ " b.DocCode,b.OriginalPrice,b.SalesPrice,b.Title ,b.CoverImage,b.CoverImageUrl,b.FormId,\n" |
J |
1655 |
+ " b.EffectiveStartDate,b.EffectiveEndDate,b.Status as PanicBuyingStatus,b.VisiteTimes,b.SharedTimes,b.OrderTimes \n" |
b326b8
|
1656 |
+ " from t710703 a \n" |
f161ef
|
1657 |
+ " join t710802H b on a.MatCode = b.DocCode \n" |
b326b8
|
1658 |
+ " where a.OpenId = @OpenId \n" |
J |
1659 |
+ " order by a.MatName asc \n" ; |
|
1660 |
try { |
a92f52
|
1661 |
List<Map<String,Object>> list = this.jdbcTemplate.queryForList(sql) ; |
b326b8
|
1662 |
List<LiveGoodsEntity> liveGoodsEntities = new ArrayList<LiveGoodsEntity>(); |
J |
1663 |
for (int i = 0; list != null&& i < list.size(); i++) { |
|
1664 |
liveGoodsEntities.add(getGoodsEntity(list.get(i))); |
|
1665 |
} |
|
1666 |
return liveGoodsEntities ; |
|
1667 |
}catch(DataAccessException e){ |
|
1668 |
if (e instanceof EmptyResultDataAccessException) { |
|
1669 |
return null ; |
|
1670 |
} else { |
|
1671 |
throw e ; |
|
1672 |
} |
|
1673 |
}catch(Exception e){ |
|
1674 |
throw e ; |
|
1675 |
} |
|
1676 |
} |
f161ef
|
1677 |
|
721aee
|
1678 |
|
J |
1679 |
@Override |
|
1680 |
public LiveGoodsEntity getLiveGoodsEntity(Long goodsId) { |
|
1681 |
String sql = " set nocount on ; \n" |
a92f52
|
1682 |
+ " declare @GoodsId bigint = "+goodsId+" \n" |
721aee
|
1683 |
+ " select top 1 a.GoodsId,a.MatCode,a.MatName,a.Special,a.CoverImgUrl,\n" |
J |
1684 |
+ " a.PriceType,a.Price,a.Price2,a.URL,a.AuditId,a.AuditStatus,a.ThirdPartyTag, \n" |
|
1685 |
+ " a.DepositDocCode,a.DepositRowId, \n" |
|
1686 |
+ " case when exists(select 1 from t710704 g where a.GoodsId = g.GoodsId) then 1 else 0 end as isAddedToRoom, \n" |
4f0006
|
1687 |
+ " b.DocCode,b.OriginalPrice,b.SalesPrice,b.Title ,b.CoverImage,b.CoverImageUrl,b.FormId, \n" |
J |
1688 |
+ " b.EffectiveStartDate,b.EffectiveEndDate,b.Status as PanicBuyingStatus,b.VisiteTimes,b.SharedTimes,b.OrderTimes \n" |
721aee
|
1689 |
+ " from t710703 a \n" |
J |
1690 |
+ " join t710802H b on a.MatCode = b.DocCode \n" |
|
1691 |
+ " where a.GoodsId = @GoodsId \n" |
|
1692 |
+ " order by a.MatName asc \n" ; |
|
1693 |
try { |
a92f52
|
1694 |
Map<String,Object> map = this.jdbcTemplate.queryForMap(sql) ; |
721aee
|
1695 |
if (map!=null) { |
J |
1696 |
return getGoodsEntity(map); |
|
1697 |
}else { |
|
1698 |
return null; |
|
1699 |
} |
|
1700 |
|
|
1701 |
}catch(DataAccessException e){ |
|
1702 |
if (e instanceof EmptyResultDataAccessException) { |
|
1703 |
return null ; |
|
1704 |
} else { |
|
1705 |
throw e ; |
|
1706 |
} |
|
1707 |
}catch(Exception e){ |
|
1708 |
throw e ; |
|
1709 |
} |
|
1710 |
} |
|
1711 |
|
f161ef
|
1712 |
@Override |
J |
1713 |
public List<LiveGoodsEntity> getGoodsListForImportRoom(Integer roomId,String openId) { |
|
1714 |
String sql = " set nocount on ; \n" |
5a96bd
|
1715 |
+ " declare @RoomId int = "+roomId+",@OpenId varchar(200) = "+ GridUtils.prossSqlParm(openId)+" \n" |
f161ef
|
1716 |
+ " select a.GoodsId,a.MatCode,a.MatName,a.Special,a.CoverImgUrl,\n" |
J |
1717 |
+ " a.PriceType,a.Price,a.Price2,a.URL,a.AuditId,a.AuditStatus,a.ThirdPartyTag, \n" |
|
1718 |
+ " a.DepositDocCode,a.DepositRowId, \n" |
|
1719 |
+ " case when exists(select 1 from t710704 g where a.GoodsId = g.GoodsId) then 1 else 0 end as isAddedToRoom, \n" |
4f0006
|
1720 |
+ " b.DocCode,b.OriginalPrice,b.SalesPrice,b.Title ,b.CoverImage,b.CoverImageUrl,b.FormId, \n" |
J |
1721 |
+ " b.EffectiveStartDate,b.EffectiveEndDate,b.Status as PanicBuyingStatus,b.VisiteTimes,b.SharedTimes,b.OrderTimes \n" |
f161ef
|
1722 |
+ " from t710703 a \n" |
J |
1723 |
+ " join t710802H b on a.MatCode = b.DocCode \n" |
|
1724 |
+ " where a.OpenId = @OpenId and a.AuditStatus = 2 \n" |
|
1725 |
+ " and not exists(select 1 from t710704 c where c.RoomId = @RoomId and a.GoodsId = c.GoodsId) \n" |
|
1726 |
+ " order by a.MatName asc \n" ; |
|
1727 |
try { |
a92f52
|
1728 |
List<Map<String,Object>> list = this.jdbcTemplate.queryForList(sql) ; |
f161ef
|
1729 |
List<LiveGoodsEntity> liveGoodsEntities = new ArrayList<LiveGoodsEntity>(); |
J |
1730 |
for (int i = 0; list != null&& i < list.size(); i++) { |
|
1731 |
liveGoodsEntities.add(getGoodsEntity(list.get(i))); |
|
1732 |
} |
|
1733 |
return liveGoodsEntities ; |
|
1734 |
}catch(DataAccessException e){ |
|
1735 |
if (e instanceof EmptyResultDataAccessException) { |
|
1736 |
return null ; |
|
1737 |
} else { |
|
1738 |
throw e ; |
|
1739 |
} |
|
1740 |
}catch(Exception e){ |
|
1741 |
throw e ; |
|
1742 |
} |
|
1743 |
} |
|
1744 |
|
b326b8
|
1745 |
|
J |
1746 |
@Override |
a6a76f
|
1747 |
public List<LiveGoodsEntity> getGoodsList(Integer roomId,String shopCcCode,String openId) { |
F |
1748 |
String sql = " set nocount on ; \n" |
a92f52
|
1749 |
+ " declare @RoomId int = "+roomId+",@ShopCcCode varchar(50) = "+GridUtils.prossSqlParm(shopCcCode)+",@OpenId varchar(200) = "+GridUtils.prossSqlParm(openId)+" ,@DefaultBrand varchar(50) ,@Telephone varchar(50) \n" |
a6a76f
|
1750 |
+ " declare @UserId varchar(50) ,@isStartupLeagueShopCcCode int \n" |
F |
1751 |
+ " select @isStartupLeagueShopCcCode = a.isStartupLeagueShopCcCode from t714001 a \n" |
|
1752 |
+ " select top 1 @Telephone = a.Tel from t730102 a where a.OpenId = @OpenId \n" |
|
1753 |
+ " if isnull(@Telephone,'') <> '' \n" |
|
1754 |
+ " begin \n" |
|
1755 |
+ " select top 1 @UserId = UserId from t700107 a where a.Mobile = @Telephone and isnull(a.isAiRadarUser,0) = 1" |
|
1756 |
+ " if isnull(@UserId,'') <> '' \n" |
|
1757 |
+ " begin \n" |
|
1758 |
+ " select top 1 @DefaultBrand = DefaultBrand \n" |
|
1759 |
+ " from _sys_LoginUser \n" |
|
1760 |
+ " where isnull(WeiXinCorpUserId,'') <> '' and WeiXinCorpUserId = @UserId and inActive<>1 \n" |
|
1761 |
+ " end \n" |
|
1762 |
+ " end \n" |
|
1763 |
+ " select a.GoodsId,a.MatCode,b.MatName,b.Special,b.PhotoPath,a.CoverImgUrl,\n" |
|
1764 |
+ " a.PriceType,a.Price,a.Price2,a.URL,a.AuditId,a.AuditStatus,a.ThirdPartyTag, \n" |
|
1765 |
+ " a.DepositDocCode,a.DepositRowId, \n" |
|
1766 |
+ " case when exists(select 1 from t710704 g where g.RoomId = @RoomId and a.GoodsId = g.GoodsId) then 1 else 0 end as isAddedToRoom \n" |
|
1767 |
+ " from t710703 a join t110503 b on a.MatCode = b.MatCode \n" |
|
1768 |
+ " where (isnull(@ShopCcCode,'') = '' or b.ShopCcCode = @ShopCcCode ) \n" |
|
1769 |
+ " and (isnull(@isStartupLeagueShopCcCode,0) = 0 \n" |
|
1770 |
+ " or (isnull(@isStartupLeagueShopCcCode,0) = 1 and (isnull(@DefaultBrand,'') = '' or b.Brand = @DefaultBrand or b.Brand in (select list from getinstr(@DefaultBrand))))) \n" |
|
1771 |
+ " and a.AuditStatus = 2 \n" //只取审核通过的商品 |
|
1772 |
+ " order by a.MatName asc \n" ; |
|
1773 |
try { |
a92f52
|
1774 |
List<Map<String,Object>> list = this.jdbcTemplate.queryForList(sql) ; |
a6a76f
|
1775 |
List<LiveGoodsEntity> liveGoodsEntities = new ArrayList<LiveGoodsEntity>(); |
F |
1776 |
for (int i = 0; list != null&& i < list.size(); i++) { |
|
1777 |
liveGoodsEntities.add(getGoodsEntity(list.get(i))); |
|
1778 |
} |
|
1779 |
return liveGoodsEntities ; |
|
1780 |
}catch(DataAccessException e){ |
|
1781 |
if (e instanceof EmptyResultDataAccessException) { |
|
1782 |
return null ; |
|
1783 |
} else { |
|
1784 |
throw e ; |
|
1785 |
} |
|
1786 |
}catch(Exception e){ |
|
1787 |
throw e ; |
|
1788 |
} |
|
1789 |
} |
|
1790 |
|
786635
|
1791 |
|
J |
1792 |
@Override |
f161ef
|
1793 |
public Integer updateGoodsSortInRoom(GoodsSortInRoomPamaraterEntity goodsSortInRoomPamaraterEntity) { |
J |
1794 |
String sql = " set nocount on ; \n" |
a92f52
|
1795 |
+ " declare @RoomId int = "+goodsSortInRoomPamaraterEntity.getRoomId()+" , @isFound int = 0 \n"; |
f161ef
|
1796 |
for (int i = 0; goodsSortInRoomPamaraterEntity!=null&&goodsSortInRoomPamaraterEntity.getGoodsSortList()!=null&& i < goodsSortInRoomPamaraterEntity.getGoodsSortList().size(); i++) { |
J |
1797 |
GoodsSortInRoomEntity goodsSortInRoomEntity = goodsSortInRoomPamaraterEntity.getGoodsSortList().get(i); |
|
1798 |
sql += " update a set DocItem = " + goodsSortInRoomEntity.getDocItem() + " from t710704 a where a.RoomId = @RoomId and a.GoodsId = " + goodsSortInRoomEntity.getGoodsId() + " \n" |
|
1799 |
+ " set @isFound = isnull(@isFound,0) + 1 \n"; |
|
1800 |
} |
|
1801 |
sql += " select @isFound as isFound \n"; |
|
1802 |
try { |
a92f52
|
1803 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
f161ef
|
1804 |
}catch(DataAccessException e){ |
J |
1805 |
if (e instanceof EmptyResultDataAccessException) { |
|
1806 |
return null ; |
|
1807 |
} else { |
|
1808 |
throw e ; |
|
1809 |
} |
|
1810 |
}catch(Exception e){ |
|
1811 |
throw e ; |
|
1812 |
} |
|
1813 |
} |
|
1814 |
|
|
1815 |
@Override |
b326b8
|
1816 |
public List<LiveGoodsEntity> getGoodsListInRoom(Integer roomId) { |
786635
|
1817 |
String sql = " set nocount on ; \n" |
a92f52
|
1818 |
+ " declare @RoomId int = "+roomId+" \n" |
f161ef
|
1819 |
+ " select a.DocItem,a.GoodsId,b.MatCode,a.MatName,a.CoverImg,a.Url,\n" |
J |
1820 |
+ " b.PriceType,a.Price,a.Price2,a.RoomId,a.OnSale, \n" |
4f0006
|
1821 |
+ " c.DocCode,c.OriginalPrice,c.SalesPrice,c.Title ,c.CoverImage,c.CoverImageUrl,c.FormId,\n" |
J |
1822 |
+ " c.EffectiveStartDate,c.EffectiveEndDate,c.Status as PanicBuyingStatus,c.VisiteTimes,c.SharedTimes,c.OrderTimes \n" |
f161ef
|
1823 |
+ " from t710704 a join t710703 b on a.GoodsId = b.GoodsId \n" |
J |
1824 |
+ " join t710802H c on b.MatCode = c.DocCode \n" //关联活动表 |
|
1825 |
+ " where a.RoomId = @RoomId \n" |
|
1826 |
+ " order by a.DocItem asc,a.MatName asc \n" ; |
786635
|
1827 |
try { |
a92f52
|
1828 |
List<Map<String,Object>> list = this.jdbcTemplate.queryForList(sql) ; |
786635
|
1829 |
List<LiveGoodsEntity> liveGoodsEntities = new ArrayList<LiveGoodsEntity>(); |
J |
1830 |
for (int i = 0; list != null&& i < list.size(); i++) { |
|
1831 |
liveGoodsEntities.add(getGoodsEntity(list.get(i))); |
|
1832 |
} |
|
1833 |
return liveGoodsEntities ; |
|
1834 |
}catch(DataAccessException e){ |
|
1835 |
if (e instanceof EmptyResultDataAccessException) { |
|
1836 |
return null ; |
|
1837 |
} else { |
|
1838 |
throw e ; |
|
1839 |
} |
|
1840 |
}catch(Exception e){ |
|
1841 |
throw e ; |
|
1842 |
} |
|
1843 |
} |
|
1844 |
|
|
1845 |
|
ae2a1f
|
1846 |
|
J |
1847 |
@Override |
|
1848 |
public LiveGoodsEntity getGoodsInRoom(Integer roomId,Long goodsId) { |
|
1849 |
String sql = " set nocount on ; \n" |
a92f52
|
1850 |
+ " declare @RoomId int = "+roomId+" , @GoodsId bigint = "+goodsId+" \n" |
ae2a1f
|
1851 |
+ " select a.DocItem,a.GoodsId,b.MatCode,a.MatName,a.CoverImg,a.Url,\n" |
J |
1852 |
+ " b.PriceType,a.Price,a.Price2,a.RoomId,a.OnSale, \n" |
|
1853 |
+ " c.DocCode,c.OriginalPrice,c.SalesPrice,c.Title ,c.CoverImage,c.CoverImageUrl,c.FormId,\n" |
|
1854 |
+ " c.EffectiveStartDate,c.EffectiveEndDate,c.Status as PanicBuyingStatus,c.VisiteTimes,c.SharedTimes,c.OrderTimes \n" |
|
1855 |
+ " from t710704 a join t710703 b on a.GoodsId = b.GoodsId \n" |
|
1856 |
+ " join t710802H c on b.MatCode = c.DocCode \n" //关联活动表 |
|
1857 |
+ " where a.RoomId = @RoomId and a.GoodsId = @GoodsId \n" |
|
1858 |
+ " order by a.DocItem asc,a.MatName asc \n" ; |
|
1859 |
try { |
a92f52
|
1860 |
Map<String,Object> map = this.jdbcTemplate.queryForMap(sql) ; |
ae2a1f
|
1861 |
if (map !=null) { |
J |
1862 |
return getGoodsEntity(map) ; |
|
1863 |
}else { |
|
1864 |
return null ; |
|
1865 |
} |
|
1866 |
}catch(DataAccessException e){ |
|
1867 |
if (e instanceof EmptyResultDataAccessException) { |
|
1868 |
return null ; |
|
1869 |
} else { |
|
1870 |
throw e ; |
|
1871 |
} |
|
1872 |
}catch(Exception e){ |
|
1873 |
throw e ; |
|
1874 |
} |
|
1875 |
} |
|
1876 |
|
a6a76f
|
1877 |
@Override |
F |
1878 |
public LiveGoodsEntity getGoodsEntity(Long goodsId) { |
|
1879 |
String sql = " set nocount on ; \n" |
a92f52
|
1880 |
+ " declare @GoodsId bigint = "+goodsId+" \n" |
a6a76f
|
1881 |
+ " select top 1 a.GoodsId,a.MatCode,b.MatName,b.Special,b.PhotoPath,a.CoverImgUrl,\n" |
F |
1882 |
+ " a.PriceType,a.Price,a.Price2,a.URL,a.AuditId,a.AuditStatus,a.ThirdPartyTag, \n" |
|
1883 |
+ " a.DepositDocCode,a.DepositRowId \n" |
|
1884 |
+ " from t710703 a join t110503 b on a.MatCode = b.MatCode \n" |
|
1885 |
+ " where a.GoodsId = @GoodsId \n" ; |
|
1886 |
try { |
a92f52
|
1887 |
Map<String,Object> map = this.jdbcTemplate.queryForMap(sql) ; |
a6a76f
|
1888 |
return getGoodsEntity(map) ; |
F |
1889 |
}catch(DataAccessException e){ |
|
1890 |
if (e instanceof EmptyResultDataAccessException) { |
|
1891 |
return null ; |
|
1892 |
} else { |
|
1893 |
throw e ; |
|
1894 |
} |
|
1895 |
}catch(Exception e){ |
|
1896 |
throw e ; |
|
1897 |
} |
|
1898 |
} |
|
1899 |
|
|
1900 |
@Override |
eb9861
|
1901 |
public List<LiveGoodsEntity> getGoodsEntityForPanicBuyingByAuditing() { |
J |
1902 |
String sql = " set nocount on ; \n" |
|
1903 |
+ " select a.GoodsId,a.MatCode,a.MatName,a.CoverImgUrl,\n" |
|
1904 |
+ " a.PriceType,a.Price,a.Price2,a.URL,a.AuditId,a.AuditStatus,a.ThirdPartyTag,\n" |
|
1905 |
+ " a.DepositDocCode,a.DepositRowId \n" |
|
1906 |
+ " from t710703 a \n" |
|
1907 |
+ " where a.AuditStatus = 0 \n" |
|
1908 |
+ " union \n" |
|
1909 |
+ " select a.GoodsId,a.MatCode,a.MatName,a.CoverImgUrl,\n" |
|
1910 |
+ " a.PriceType,a.Price,a.Price2,a.URL,a.AuditId,a.AuditStatus,a.ThirdPartyTag,\n" |
|
1911 |
+ " a.DepositDocCode,a.DepositRowId \n" |
|
1912 |
+ " from t710703 a \n" |
|
1913 |
+ " where a.AuditStatus = 1 \n" ; |
|
1914 |
|
|
1915 |
try { |
|
1916 |
List<LiveGoodsEntity> liveGoodsList = new ArrayList<LiveGoodsEntity>(); |
|
1917 |
List<Map<String,Object>> list = this.jdbcTemplate.queryForList(sql) ; |
|
1918 |
for (int i = 0; list!= null&& i < list.size(); i++) { |
|
1919 |
liveGoodsList.add(getGoodsEntity(list.get(i))) ; |
|
1920 |
} |
|
1921 |
return liveGoodsList ; |
|
1922 |
}catch(DataAccessException e){ |
|
1923 |
if (e instanceof EmptyResultDataAccessException) { |
|
1924 |
return null ; |
|
1925 |
} else { |
|
1926 |
throw e ; |
|
1927 |
} |
|
1928 |
}catch(Exception e){ |
|
1929 |
throw e ; |
|
1930 |
} |
|
1931 |
} |
|
1932 |
|
|
1933 |
@Override |
5dc0cf
|
1934 |
public LiveGoodsEntity getGoodsEntityForPanicBuying(String docCode ) { |
J |
1935 |
String sql = " set nocount on ; \n" |
a92f52
|
1936 |
+ " declare @MatCode varchar(50) = "+GridUtils.prossSqlParm(docCode)+" \n" |
3073fd
|
1937 |
+ " select top 1 a.GoodsId,a.MatCode,a.MatName,a.CoverImgUrl,\n" |
J |
1938 |
+ " a.PriceType,a.Price,a.Price2,a.URL,a.AuditId,a.AuditStatus,a.ThirdPartyTag,\n" |
|
1939 |
+ " a.DepositDocCode,a.DepositRowId \n" |
5dc0cf
|
1940 |
+ " from t710703 a \n" |
J |
1941 |
+ " where a.MatCode = isnull(@MatCode,'') \n" ; |
|
1942 |
try { |
a92f52
|
1943 |
Map<String,Object> map = this.jdbcTemplate.queryForMap(sql) ; |
5dc0cf
|
1944 |
return getGoodsEntity(map) ; |
J |
1945 |
}catch(DataAccessException e){ |
|
1946 |
if (e instanceof EmptyResultDataAccessException) { |
|
1947 |
return null ; |
|
1948 |
} else { |
|
1949 |
throw e ; |
|
1950 |
} |
|
1951 |
}catch(Exception e){ |
|
1952 |
throw e ; |
|
1953 |
} |
|
1954 |
} |
|
1955 |
|
|
1956 |
@Override |
a6a76f
|
1957 |
public LiveGoodsEntity getGoodsEntity(String matCode ,String depositDocCode,String depositRowId) { |
F |
1958 |
String sql = " set nocount on ; \n" |
a92f52
|
1959 |
+ " declare @MatCode varchar(50) = "+GridUtils.prossSqlParm(matCode)+",@DepositDocCode varchar(50) = "+GridUtils.prossSqlParm(depositDocCode)+", @DepositRowId varchar(20) = "+GridUtils.prossSqlParm(depositRowId)+" \n" |
a6a76f
|
1960 |
+ " select top 1 a.GoodsId,a.MatCode,b.MatName,b.Special,b.PhotoPath,a.CoverImgUrl,\n" |
F |
1961 |
+ " a.PriceType,a.Price,a.Price2,a.URL,a.AuditId,a.AuditStatus,a.ThirdPartyTag,a.DepositDocCode,a.DepositRowId \n" |
|
1962 |
+ " from t710703 a join t110503 b on a.MatCode = b.MatCode \n" |
|
1963 |
+ " where a.MatCode = isnull(@MatCode,'') and a.DepositDocCode = isnull(@DepositDocCode,'') and a.DepositRowId = isnull( @DepositRowId,'') \n" ; |
|
1964 |
try { |
a92f52
|
1965 |
Map<String,Object> map = this.jdbcTemplate.queryForMap(sql) ; |
a6a76f
|
1966 |
return getGoodsEntity(map) ; |
F |
1967 |
}catch(DataAccessException e){ |
|
1968 |
if (e instanceof EmptyResultDataAccessException) { |
|
1969 |
return null ; |
|
1970 |
} else { |
|
1971 |
throw e ; |
|
1972 |
} |
|
1973 |
}catch(Exception e){ |
|
1974 |
throw e ; |
|
1975 |
} |
|
1976 |
} |
|
1977 |
|
|
1978 |
private LiveGoodsEntity getGoodsEntity(Map<String,Object> map) { |
|
1979 |
if (map == null) return null ; |
|
1980 |
LiveGoodsEntity goodsEntity = new LiveGoodsEntity() ; |
64db07
|
1981 |
goodsEntity.setRoomId((Integer)map.get("RoomId")) ; |
a6a76f
|
1982 |
goodsEntity.setGoodsId((Long)map.get("GoodsId")) ; |
F |
1983 |
goodsEntity.setMatCode((String)map.get("MatCode")) ; |
|
1984 |
goodsEntity.setMatName((String)map.get("MatName")) ; |
|
1985 |
goodsEntity.setSpecial((String)map.get("Special")) ; |
|
1986 |
goodsEntity.setPhotoPath((String)map.get("PhotoPath")) ; |
64db07
|
1987 |
goodsEntity.setCoverImg((String)map.get("CoverImg")) ; |
a6a76f
|
1988 |
goodsEntity.setCoverImgUrl((String)map.get("CoverImgUrl")) ; |
F |
1989 |
goodsEntity.setPriceType((Integer)map.get("PriceType")) ; |
|
1990 |
goodsEntity.setPrice(map.get("Price")==null?null:Double.valueOf(map.get("Price").toString())) ; |
|
1991 |
goodsEntity.setPrice2(map.get("Price2")==null?null:Double.valueOf(map.get("Price2").toString())) ; |
|
1992 |
goodsEntity.setUrl((String)map.get("URL")) ; |
|
1993 |
goodsEntity.setAuditId((Long)map.get("AuditId")) ; |
|
1994 |
goodsEntity.setAuditStatus((Integer)map.get("AuditStatus")) ; |
|
1995 |
goodsEntity.setThirdPartyTag((Integer)map.get("ThirdPartyTag")) ; |
|
1996 |
goodsEntity.setDepositAmount(map.get("DepositAmount")==null?null:Double.valueOf(map.get("DepositAmount").toString())) ; |
|
1997 |
goodsEntity.setDepositDocCode((String)map.get("DepositDocCode")) ; |
|
1998 |
goodsEntity.setDepositRowId((String)map.get("DepositRowId")) ; |
|
1999 |
goodsEntity.setAddedToRoom(map.get("isAddedToRoom")!=null&&map.get("isAddedToRoom").equals(1)?true:false) ; |
64db07
|
2000 |
goodsEntity.setOnSale(map.get("OnSale")==null?0:(Integer)map.get("OnSale")) ; |
f161ef
|
2001 |
goodsEntity.setDocItem(map.get("DocItem")==null?0:(Integer)map.get("DocItem")) ; |
J |
2002 |
|
|
2003 |
//增加一堆与活动相关的参数 |
|
2004 |
goodsEntity.setDocCode(map.get("DocCode")==null?"":(String)map.get("DocCode")); |
|
2005 |
goodsEntity.setFormId(map.get("FormId")==null?null:(Integer)map.get("FormId")); |
|
2006 |
goodsEntity.setTitle(map.get("Title")==null?"":(String)map.get("Title")); |
|
2007 |
goodsEntity.setCoverImage(map.get("CoverImage")==null?"":(String)map.get("CoverImage")); |
|
2008 |
goodsEntity.setCoverImageUrl(map.get("CoverImageUrl")==null?"":(String)map.get("CoverImageUrl")); |
|
2009 |
goodsEntity.setOriginalPrice(map.get("OriginalPrice")== null?0L:Double.parseDouble(map.get("OriginalPrice").toString())); |
|
2010 |
goodsEntity.setSalesPrice(map.get("SalesPrice")== null?0L:Double.parseDouble(map.get("SalesPrice").toString())); |
|
2011 |
goodsEntity.setNumberOfTeam(map.get("NumberOfTeam")== null?0:(Integer)map.get("NumberOfTeam")); |
|
2012 |
goodsEntity.setEffectiveStartDate(map.get("EffectiveStartDate")==null?null:(Date)map.get("EffectiveStartDate")); |
|
2013 |
goodsEntity.setEffectiveEndDate(map.get("EffectiveEndDate")==null?null:(Date)map.get("EffectiveEndDate")); |
|
2014 |
goodsEntity.setPanicBuyingStatus(map.get("PanicBuyingStatus")==null?null:(Integer)map.get("PanicBuyingStatus")); |
e8fa0b
|
2015 |
goodsEntity.setVisiteTimes(map.get("VisiteTimes")==null?0:(Integer)map.get("VisiteTimes")); |
J |
2016 |
goodsEntity.setSharedTimes(map.get("SharedTimes")==null?0:(Integer)map.get("SharedTimes")); |
|
2017 |
goodsEntity.setOrderTimes(map.get("OrderTimes")==null?0:(Integer)map.get("OrderTimes")); |
a6a76f
|
2018 |
|
F |
2019 |
return goodsEntity; |
|
2020 |
} |
|
2021 |
|
|
2022 |
@Override |
|
2023 |
public Integer updateLiveStatus(Integer roomId ,Integer liveStatus) { |
|
2024 |
String sql = " set nocount on ; \n" |
a92f52
|
2025 |
+ " declare @RoomId int = "+roomId+" ,@LiveStatus int = "+liveStatus+" \n" |
a6a76f
|
2026 |
+ " update a set LiveStatus = @LiveStatus \n" |
F |
2027 |
+ " from t710701 a \n" |
|
2028 |
+ " where a.RoomId = @RoomId \n" |
|
2029 |
+ " select @@rowcount \n" ; |
|
2030 |
try { |
a92f52
|
2031 |
Integer ret = this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
a6a76f
|
2032 |
return ret ; |
F |
2033 |
}catch(DataAccessException e){ |
|
2034 |
if (e instanceof EmptyResultDataAccessException) { |
|
2035 |
return null ; |
|
2036 |
} else { |
|
2037 |
throw e ; |
|
2038 |
} |
|
2039 |
}catch(Exception e){ |
|
2040 |
throw e ; |
|
2041 |
} |
|
2042 |
} |
|
2043 |
|
|
2044 |
@Override |
|
2045 |
public LiveRoomEntity getLiveStatus(String shopCcCode ) { |
|
2046 |
String sql = " set nocount on ; \n" |
a92f52
|
2047 |
+ " declare @ShopCcCode varchar(2000) = "+GridUtils.prossSqlParm(shopCcCode)+" \n" |
a6a76f
|
2048 |
+ " select RoomId,RoomName,CoverImg,LiveStatus,StartTime,EndTime,AnchorName,AnchorImg,ShopCcCode, \n" |
F |
2049 |
+ " DATEDIFF(SECOND,getdate(), a.StartTime) as LiveBalanceSecond, \n" |
|
2050 |
+ " a.isShowBannerPhotoOnHomePage , a.BannerPhoto,a.BannerPhotoUrl \n" |
|
2051 |
+ " from t710701 a \n" |
|
2052 |
+ " where (isnull(@ShopCcCode,'') = '' or a.ShopCcCode = @ShopCcCode) \n" |
|
2053 |
+ " and a.LiveStatus in (101,102) \n" ; // 只查询状态: 101: 直播中, 102: 未开始 |
|
2054 |
LiveRoomEntity liveRoomEntity = new LiveRoomEntity() ; |
|
2055 |
try { |
a92f52
|
2056 |
List<Map<String,Object>> list = this.jdbcTemplate.queryForList(sql) ; |
a6a76f
|
2057 |
if (list != null) { |
F |
2058 |
List<RoomInfo> roomInfoList = new ArrayList<RoomInfo>(list.size()) ; |
|
2059 |
for (int i = 0; i < list.size() ; i ++) { |
|
2060 |
roomInfoList.add(getRoomInfo(list.get(i), liveRoomEntity) ) ; |
|
2061 |
} |
|
2062 |
liveRoomEntity.setTotal(list.size()); |
|
2063 |
liveRoomEntity.setRoomInfo(roomInfoList); |
|
2064 |
} |
|
2065 |
return liveRoomEntity ; |
|
2066 |
}catch(DataAccessException e){ |
|
2067 |
if (e instanceof EmptyResultDataAccessException) { |
|
2068 |
return null ; |
|
2069 |
} else { |
|
2070 |
throw e ; |
|
2071 |
} |
|
2072 |
}catch(Exception e){ |
|
2073 |
throw e ; |
|
2074 |
} |
|
2075 |
} |
ae2a1f
|
2076 |
|
J |
2077 |
|
|
2078 |
@Override |
|
2079 |
public Integer addLiveSubscribeUser(LiveSubscribeUserEntity liveSubscribeUserEntity ) { |
a92f52
|
2080 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
J |
2081 |
|
ae2a1f
|
2082 |
try { |
J |
2083 |
Date subscribeDateTime = null ; |
|
2084 |
if (liveSubscribeUserEntity.getSubscribeTime() != null) { |
|
2085 |
subscribeDateTime = new Date(liveSubscribeUserEntity.getSubscribeTime()*1000); |
|
2086 |
} else { |
|
2087 |
subscribeDateTime = new Date(); |
|
2088 |
} |
a92f52
|
2089 |
|
J |
2090 |
String sql = " set nocount on ; \n" |
|
2091 |
+ " declare @RoomId int = "+liveSubscribeUserEntity.getRoomId()+",@OpenId varchar(200) = "+GridUtils.prossSqlParm(liveSubscribeUserEntity.getOpenId()) |
|
2092 |
+",@SubscribeTime bigint = "+liveSubscribeUserEntity.getSubscribeTime() |
|
2093 |
+",@SubscribeDateTime datetime = "+GridUtils.prossSqlParm(subscribeDateTime==null?null:sdf.format(subscribeDateTime)) |
|
2094 |
+",@RoomStatus int = "+liveSubscribeUserEntity.getRoomStatus()+" \n" |
|
2095 |
+ " declare @NickName nvarchar(400),@WeiXinAvatarUnid varchar(50) \n" |
|
2096 |
+ " declare @myrowcount int \n" |
|
2097 |
+ " update a set SubscribeTime = @SubscribeTime,SubscribeDateTime=@SubscribeDateTime,RoomStatus = @RoomStatus \n" |
|
2098 |
+ " from t710708 a where a.RoomId = @RoomId and a.OpenId = @OpenId \n" |
|
2099 |
+ " select @myrowcount = @@rowcount \n" |
|
2100 |
+ " if @myrowcount = 0 \n" |
|
2101 |
+ " begin \n" |
|
2102 |
+ " select @NickName = a.NickName,@WeiXinAvatarUnid = a.WeiXinAvatarUnid from t730102 a where a.OpenId = @OpenId \n" |
|
2103 |
+ " insert into t710708(RoomId,OpenId,NickName,WeiXinAvatarUnid,SubscribeTime,SubscribeDateTime,RoomStatus) \n" |
|
2104 |
+ " values(@RoomId,@OpenId,@NickName,@WeiXinAvatarUnid,@SubscribeTime,@SubscribeDateTime,@RoomStatus ) \n" |
|
2105 |
+ " select @myrowcount = @@rowcount \n" |
|
2106 |
+ " end \n" |
|
2107 |
+ " update a set SubscribeTimes = isnull(a.SubscribeTimes,0) + 1 from t710701 a where a.RoomId = @RoomId \n" |
|
2108 |
+ " select @myrowcount as myrowcount \n" ; // 订阅或者取消订阅时直播间状态,取值:101(直播中),102(未开始),103(已结束) |
|
2109 |
|
|
2110 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
ae2a1f
|
2111 |
|
J |
2112 |
}catch(DataAccessException e){ |
|
2113 |
if (e instanceof EmptyResultDataAccessException) { |
|
2114 |
return null ; |
|
2115 |
} else { |
|
2116 |
throw e ; |
|
2117 |
} |
|
2118 |
}catch(Exception e){ |
|
2119 |
throw e ; |
|
2120 |
} |
|
2121 |
} |
|
2122 |
|
|
2123 |
@Override |
|
2124 |
public Integer deleteLiveSubscribeUser(Integer roomId,String openId) { |
|
2125 |
String sql = " set nocount on ; \n" |
a92f52
|
2126 |
+ " declare @RoomId int = "+roomId+",@OpenId varchar(200) = "+GridUtils.prossSqlParm(openId)+" \n" |
ae2a1f
|
2127 |
+ " declare @myrowcount int \n" |
J |
2128 |
+ " delete a \n" |
|
2129 |
+ " from t710708 a where a.RoomId = @RoomId and a.OpenId = @OpenId \n" |
|
2130 |
+ " select @myrowcount = @@rowcount \n" |
6e0012
|
2131 |
+ " update a set SubscribeTimes = isnull(a.SubscribeTimes,0) - 1 from t710701 a where a.RoomId = @RoomId \n" |
ae2a1f
|
2132 |
+ " select @myrowcount as myrowcount \n" ; // 订阅或者取消订阅时直播间状态,取值:101(直播中),102(未开始),103(已结束) |
J |
2133 |
try { |
|
2134 |
|
a92f52
|
2135 |
return this.jdbcTemplate.queryForObject(sql,Integer.class) ; |
ae2a1f
|
2136 |
|
J |
2137 |
}catch(DataAccessException e){ |
|
2138 |
if (e instanceof EmptyResultDataAccessException) { |
|
2139 |
return null ; |
|
2140 |
} else { |
|
2141 |
throw e ; |
|
2142 |
} |
|
2143 |
}catch(Exception e){ |
|
2144 |
throw e ; |
|
2145 |
} |
|
2146 |
} |
a6a76f
|
2147 |
} |