|
@@ -0,0 +1,51 @@
|
|
|
+package cn.iselab.mooctest.site.web.logic.impl;
|
|
|
+
|
|
|
+import cn.iselab.mooctest.site.dao.User2SalesPackageDao;
|
|
|
+import cn.iselab.mooctest.site.service.OpenId2UserIdService;
|
|
|
+import cn.iselab.mooctest.site.service.User2ThemeService;
|
|
|
+import cn.iselab.mooctest.site.service.UserPackageService;
|
|
|
+import cn.iselab.mooctest.site.web.logic.ProductProcessLogic;
|
|
|
+import org.json.JSONArray;
|
|
|
+import org.json.JSONObject;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Author: xuexb
|
|
|
+ * @Date: 2019.7.5 1:00
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ProductProcessLogicImpl implements ProductProcessLogic {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OpenId2UserIdService openId2UserIdService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private User2ThemeService user2ThemeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private User2SalesPackageDao user2SalesPackageDao;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean sendProduct(JSONObject productDetails) {
|
|
|
+ try{
|
|
|
+ JSONArray entities = productDetails.getJSONArray("product2entities");
|
|
|
+ Long userId = openId2UserIdService.findUserIdByOpenId(productDetails.getString("user"));
|
|
|
+ for (int i=0; i<entities.length(); i++) {
|
|
|
+ JSONObject entity = entities.getJSONObject(i);
|
|
|
+ switch (entity.getString("entityType")){//根据不同Type进行不同处理
|
|
|
+ case "THEME":
|
|
|
+ if (user2ThemeService.findByUserIdAndThemeId(userId, entity.getLong("entityId"))==null)
|
|
|
+ user2ThemeService.createRelation(userId, entity.getLong("entityId"));//关联不存在则建立关联
|
|
|
+ break;
|
|
|
+ case "USERPACKAGE":
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+}
|