Skip to content

Commit de0b5d3

Browse files
author
wuxw7
committed
商品服务 购买 商品目录 开发完成待测试
1 parent 7096abd commit de0b5d3

8 files changed

Lines changed: 621 additions & 0 deletions

File tree

ShopService/doc/savaBuyShop.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"orders": {
3+
"appId": "外系统ID,分配得到",
4+
"transactionId": "100000000020180409224736000001",
5+
"userId": "用户ID",
6+
"orderTypeCd": "订单类型,查询,受理",
7+
"requestTime": "20180409224736",
8+
"remark": "备注",
9+
"sign": "这个服务是否要求MD5签名",
10+
"attrs": [{
11+
"specCd": "配置的字段ID",
12+
"value": "具体值"
13+
}]
14+
},
15+
"business": [{
16+
"serviceCode": "buy.shop.info",
17+
"serviceName": "购买",
18+
"remark": "备注",
19+
"datas": {
20+
"businessBuyShop": {
21+
"shopId": "123",
22+
"buyId": "-1",
23+
"buyCount":"10"
24+
},
25+
"businessBuyShopAttr": [{
26+
"buyId": "-1",
27+
"attrId":"-1",
28+
"specCd":"1001",
29+
"value":"01"
30+
}]
31+
},
32+
"attrs": [{
33+
"specCd": "配置的字段ID",
34+
"value": "具体值"
35+
}]
36+
}]
37+
}

ShopService/src/main/java/com/java110/shop/dao/IShopServiceDao.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public interface IShopServiceDao {
6565
*/
6666
public void saveBusinessShopCatalog(Map businessShopCatalog) throws DAOException;
6767

68+
6869
/**
6970
* 查询商品信息(business过程)
7071
* 根据bId 查询商品信息
@@ -176,6 +177,20 @@ public interface IShopServiceDao {
176177
*/
177178
public void saveShopCatalogInstance(Map info) throws DAOException;
178179

180+
/**
181+
* 保存购买记录
182+
* @param businessBuyShop
183+
* @throws DAOException
184+
*/
185+
public void saveBuyShopInstance(Map businessBuyShop) throws DAOException;
186+
187+
/**
188+
* 保存商品购买记录属性
189+
* @param businessBuyShopAttr
190+
* @throws DAOException
191+
*/
192+
public void saveBuyShopAttrInstance(Map businessBuyShopAttr) throws DAOException;
193+
179194
/**
180195
* 查询商品信息(instance过程)
181196
* 根据bId 查询商品信息
@@ -235,6 +250,22 @@ public interface IShopServiceDao {
235250
*/
236251
public Map getShopCatalog(Map info) throws DAOException;
237252

253+
/**
254+
* 商品购买查询(instance)
255+
* @param info bId 信息
256+
* @return
257+
* @throws DAOException
258+
*/
259+
public Map getBuyShop(Map info) throws DAOException;
260+
261+
/**
262+
* 商品属性查询(instance)
263+
* @param info bId 信息
264+
* @return
265+
* @throws DAOException
266+
*/
267+
public List<Map> getBuyShopAttrs(Map info) throws DAOException;
268+
238269
/**
239270
* 修改商品信息
240271
* @param info 修改信息
@@ -286,4 +317,18 @@ public interface IShopServiceDao {
286317
*/
287318
public void updateShopCatalogInstance(Map info) throws DAOException;
288319

320+
321+
/**
322+
* 修改商品购买信息
323+
* @param info 修改信息
324+
* @throws DAOException
325+
*/
326+
public void updateBuyShopInstance(Map info) throws DAOException;
327+
328+
/**
329+
* 修改商品购买属性信息(instance)
330+
* @param info 修改信息
331+
* @throws DAOException
332+
*/
333+
public void updateBuyShopAttrInstance(Map info) throws DAOException;
289334
}

ShopService/src/main/java/com/java110/shop/dao/impl/ShopServiceDaoImpl.java

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,40 @@ public void saveShopCatalogInstance(Map info) throws DAOException {
362362
}
363363

364364

365+
/**
366+
* 保存购买记录
367+
* @param businessBuyShop
368+
* @throws DAOException
369+
*/
370+
@Override
371+
public void saveBuyShopInstance(Map businessBuyShop) throws DAOException {
372+
businessBuyShop.put("month", DateUtil.getCurrentMonth());
373+
logger.debug("保存商品购买记录信息 入参 businessBuyShop : {}",businessBuyShop);
374+
375+
int saveFlag = sqlSessionTemplate.insert("shopServiceDaoImpl.saveBuyShopInstance",businessBuyShop);
376+
377+
if(saveFlag < 1){
378+
throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商品购买记录数据失败:"+ JSONObject.toJSONString(businessBuyShop));
379+
}
380+
}
381+
382+
/**
383+
* 购买商品属性保存
384+
* @param businessBuyShopAttr
385+
* @throws DAOException
386+
*/
387+
@Override
388+
public void saveBuyShopAttrInstance(Map businessBuyShopAttr) throws DAOException {
389+
businessBuyShopAttr.put("month", DateUtil.getCurrentMonth());
390+
logger.debug("保存商品购买记录属性信息 入参 businessBuyShopAttr : {}",businessBuyShopAttr);
391+
392+
int saveFlag = sqlSessionTemplate.insert("shopServiceDaoImpl.saveBuyShopAttrInstance",businessBuyShopAttr);
393+
394+
if(saveFlag < 1){
395+
throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商品购买记录属性数据失败:"+ JSONObject.toJSONString(businessBuyShopAttr));
396+
}
397+
}
398+
365399
/**
366400
* 查询商品信息(instance)
367401
* @param info bId 信息
@@ -488,6 +522,40 @@ public Map getShopCatalog(Map info) throws DAOException {
488522
return shopCatalogs.get(0);
489523
}
490524

525+
/**
526+
* 商品描述查询(instance)
527+
* @param info bId 信息
528+
* @return
529+
* @throws DAOException
530+
*/
531+
@Override
532+
public Map getBuyShop(Map info) throws DAOException {
533+
logger.debug("查询商品购买信息 入参 info : {}",info);
534+
535+
List<Map> getBuyShops = sqlSessionTemplate.selectList("shopServiceDaoImpl.getBuyShop",info);
536+
if(getBuyShops == null || getBuyShops.size() == 0){
537+
return null;
538+
}
539+
if(getBuyShops.size() >1){
540+
throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:getShopCatalog,"+ JSONObject.toJSONString(info));
541+
}
542+
return getBuyShops.get(0);
543+
}
544+
545+
/**
546+
* 商品属性查询(instance)
547+
* @param info bId 信息
548+
* @return
549+
* @throws DAOException
550+
*/
551+
@Override
552+
public List<Map> getBuyShopAttrs(Map info) throws DAOException {
553+
logger.debug("查询商品购买属性信息 入参 info : {}",info);
554+
555+
List<Map> buyShopAttrs = sqlSessionTemplate.selectList("shopServiceDaoImpl.getBuyShopAttrs",info);
556+
557+
return buyShopAttrs;
558+
}
491559

492560
/**
493561
* 修改商品信息
@@ -600,4 +668,36 @@ public void updateShopCatalogInstance(Map info) throws DAOException {
600668
throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改商品目录信息Instance数据失败:"+ JSONObject.toJSONString(info));
601669
}
602670
}
671+
672+
/**
673+
* 修改商品购买信息
674+
* @param info 修改信息
675+
* @throws DAOException
676+
*/
677+
@Override
678+
public void updateBuyShopInstance(Map info) throws DAOException {
679+
logger.debug("修改商品购买信息Instance 入参 info : {}",info);
680+
681+
int saveFlag = sqlSessionTemplate.update("shopServiceDaoImpl.updateBuyShopInstance",info);
682+
683+
if(saveFlag < 1){
684+
throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改商品购买信息Instance数据失败:"+ JSONObject.toJSONString(info));
685+
}
686+
}
687+
688+
/**
689+
* 修改商品购买属性信息(instance)
690+
* @param info 修改信息
691+
* @throws DAOException
692+
*/
693+
@Override
694+
public void updateBuyShopAttrInstance(Map info) throws DAOException {
695+
logger.debug("修改商品购买属性信息Instance 入参 info : {}",info);
696+
697+
int saveFlag = sqlSessionTemplate.update("shopServiceDaoImpl.updateBuyShopAttrInstance",info);
698+
699+
if(saveFlag < 1){
700+
throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改商品购买属性信息Instance数据失败:"+ JSONObject.toJSONString(info));
701+
}
702+
}
603703
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package com.java110.shop.listener;
2+
3+
import com.alibaba.fastjson.JSONArray;
4+
import com.alibaba.fastjson.JSONObject;
5+
import com.java110.common.constant.ServiceCodeConstant;
6+
import com.java110.common.util.Assert;
7+
import com.java110.core.annotation.Java110Listener;
8+
import com.java110.core.context.DataFlowContext;
9+
import com.java110.core.factory.GenerateCodeFactory;
10+
import com.java110.entity.center.Business;
11+
import com.java110.shop.dao.IShopServiceDao;
12+
13+
/**
14+
* 如果buyId buyAttrId 填写的值为-1,则重新生成
15+
*
16+
* Created by wuxw on 2018/7/7.
17+
*/
18+
@Java110Listener(name="flushAboutBuyIdListener")
19+
public class FlushAboutBuyIdListener extends AbstractShopBusinessServiceDataFlowListener {
20+
@Override
21+
public int getOrder() {
22+
return 1;
23+
}
24+
25+
@Override
26+
public String getServiceCode() {
27+
return ServiceCodeConstant.SERVICE_CODE_BUY_SHOP_INFO;
28+
}
29+
30+
@Override
31+
public IShopServiceDao getShopServiceDaoImpl() {
32+
return null;
33+
}
34+
35+
@Override
36+
protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
37+
JSONObject data = business.getDatas();
38+
Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
39+
//刷新shopId
40+
if(data.containsKey("businessBuyShop")){
41+
JSONObject businessBuyShop = data.getJSONObject("businessBuyShop");
42+
if(!businessBuyShop.containsKey("buyId") || businessBuyShop.getString("buyId").startsWith("-")){
43+
flushShopBuyId(data);
44+
}
45+
}
46+
47+
//刷新 attrId
48+
if(data.containsKey("businessBuyShopAttr")){
49+
JSONArray businessBuyShopAttrs = data.getJSONArray("businessBuyShopAttr");
50+
for(int businessBuyShopAttrIndex = 0 ; businessBuyShopAttrIndex < businessBuyShopAttrs.size();businessBuyShopAttrIndex++){
51+
JSONObject attrObj = businessBuyShopAttrs.getJSONObject(businessBuyShopAttrIndex);
52+
if(attrObj.containsKey("attrId") && !attrObj.getString("attrId").startsWith("-")){
53+
continue;
54+
}
55+
attrObj.put("attrId",GenerateCodeFactory.getShopBuyAttrId());
56+
}
57+
}
58+
59+
}
60+
61+
@Override
62+
protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
63+
// nothing to do
64+
}
65+
66+
@Override
67+
protected void doRecover(DataFlowContext dataFlowContext, Business business) {
68+
// nothing to do
69+
}
70+
71+
/**
72+
* 刷新 商品目录ID
73+
* @param data
74+
*/
75+
private void flushShopBuyId(JSONObject data) {
76+
77+
String buyId = GenerateCodeFactory.getShopBuyId();
78+
JSONObject businessBuyShop = data.getJSONObject("businessBuyShop");
79+
businessBuyShop.put("buyId",buyId);
80+
}
81+
}

0 commit comments

Comments
 (0)