Browse Source

商户,接口

wuwen 5 years ago
parent
commit
be92a2214b

+ 16 - 0
src/main/java/com/ssj/api/controller/ApiWxController.java

@@ -39,4 +39,20 @@ public class ApiWxController extends BaseController {
     }
 	
 	
+	@IgnoreSecurity
+	@RequestMapping(value = "/jsAccessToken")
+    @ApiOperation(value = "获取jsAccessToken接口",  notes = "获取jsAccessToken接口")
+    public ResponseEntity getJSAccessToken() {
+        ResponseEntity responseEntity = new ResponseEntity();
+        try {
+        	Map<String, Object> data =tokenManager.getSSJJSAccessTokenAndTime();
+            responseEntity.success(data, "获取accessToken成功");
+        } catch (Exception e) {
+            logger.error("获取accessToken接口", e);
+            responseEntity.failure(ResponseConstant.CODE_500, "系统繁忙,请稍后重试");
+        }
+        return responseEntity;
+    }
+	
+	
 }

+ 69 - 0
src/main/java/com/ssj/bean/sys/award/domain/AwardGrantInfo.java

@@ -0,0 +1,69 @@
+package com.ssj.bean.sys.award.domain;
+
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import com.ssj.bean.common.framework.core.domain.BaseEntity;
+
+
+@Entity
+@Table(name="tb_award_grant_info")
+public class AwardGrantInfo extends BaseEntity {
+	
+	private static final long serialVersionUID = 1L;
+	
+	private String grantId;
+	
+	private String materialId;
+	
+	private Integer level;
+	
+	private Integer num;
+	
+	private Date createTime;
+
+	public String getGrantId() {
+		return grantId;
+	}
+
+	public void setGrantId(String grantId) {
+		this.grantId = grantId;
+	}
+
+	public String getMaterialId() {
+		return materialId;
+	}
+
+	public void setMaterialId(String materialId) {
+		this.materialId = materialId;
+	}
+
+	public Integer getLevel() {
+		return level;
+	}
+
+	public void setLevel(Integer level) {
+		this.level = level;
+	}
+
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public Integer getNum() {
+		return num;
+	}
+
+	public void setNum(Integer num) {
+		this.num = num;
+	}
+
+	
+	
+}

+ 9 - 0
src/main/java/com/ssj/dao/weixin/library/dao/ILibVipDao.java

@@ -138,5 +138,14 @@ public interface ILibVipDao extends JpaRepository<LibVip, String> {
 	@Query(nativeQuery = true,value = "SELECT v.* from  tb_lib_vip v  where v.activate_time>=?2  AND v.lib_id=?1 AND v.stat=1 ORDER BY v.create_time DESC LIMIT 10000")
 	public List<LibVip> findByLibIdActivateTime(String libId,Date signTime);
 	
+	int countByLibId(String libId);
+	
+	 @Query(nativeQuery = true, value = "update tb_lib_vip set lib_id = null where lib_id = ?1 ")
+	 @Modifying
+	 public void updateLibId(String libId);
+	 
+	 
+		        
+	
 	
 }

+ 4 - 0
src/main/java/com/ssj/dao/weixin/sales/dao/LibVipServiceDao.java

@@ -326,4 +326,8 @@ public interface LibVipServiceDao extends JpaRepository<LibVipService, String> {
 			" and to_days(end_time) >= to_days(now()) \n" +
 			" ORDER BY species,service_sort,correct_type,start_time limit 1;")
 	LibVipService findCorrectTypeByVipId(String vipId);
+	
+    @Query(nativeQuery = true, value = "update tb_lib_vip_service set stat = 2 where lib_id = ?1 and species='S003' ")
+    @Modifying
+    void clearServiceByLibId(String libId);
 }

+ 1 - 0
src/main/java/com/ssj/framework/core/security/manager/TokenManager.java

@@ -157,6 +157,7 @@ public interface TokenManager {
      * @return
      */
     public String getSSJJSAccessToken();
+    public Map<String,Object> getSSJJSAccessTokenAndTime();
   
     
     /**

+ 22 - 0
src/main/java/com/ssj/framework/core/security/manager/impl/RedisTokenManager.java

@@ -813,4 +813,26 @@ public class RedisTokenManager implements TokenManager {
         data.put("expires_in", jedisPool.ttl(SSJ_WX_TOKEN).intValue());
         return data;
 	}
+
+	@Override
+	public Map<String, Object> getSSJJSAccessTokenAndTime() {
+		Map<String,Object> data=new HashMap<String, Object>();
+		String jsAccessToken=get(SSJ_JSWX_TOKEN);
+        if(jsAccessToken ==null){
+            int seconds  = 0;
+            try {
+                JSONObject json =new WeixinUtil().getJsApiTicket(this.getSSJAccessToken());
+                jsAccessToken=json.getString("ticket");
+                seconds=json.getInteger("expires_in");
+            } catch (Exception e) {
+                logger.info("发生异常:JsapiTicket" + e.getMessage());
+                e.printStackTrace();
+            }
+
+            createSSJJSAccessToken(jsAccessToken,seconds);
+        }
+        data.put("access_token", jsAccessToken);
+        data.put("expires_in", jedisPool.ttl(SSJ_JSWX_TOKEN).intValue());
+        return data;
+	}
 }

+ 1 - 2
src/main/java/com/ssj/service/sys/fx/service/impl/MerchantServiceImpl.java

@@ -1506,8 +1506,7 @@ public class MerchantServiceImpl extends BaseServiceImpl<Merchant, String> imple
 					//旧套餐大于新套餐的话,就服务降级
 					if(oldmerchant.getSignType()>merchant.getSignType()
 							&& StringUtils.isNotEmpty(oldmerchant.getLibId())) {
-						//调用灿的降级服务接口
-						
+						libVipServiceService.removeLibService(oldmerchant.getLibId(), oldmerchant.getLibService());
 					}
 					//更新套餐
 					oldmerchant.setSignType(merchant.getSignType());

+ 6 - 0
src/main/java/com/ssj/service/weixin/library/service/ILibVipService.java

@@ -3,6 +3,8 @@ package com.ssj.service.weixin.library.service;
 import com.ssj.bean.weixin.libmy.domain.LibVip;
 import com.ssj.bean.weixin.sales.domain.LibVipService;
 import com.ssj.framework.core.common.service.BaseService;
+
+import org.apache.ibatis.annotations.Param;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 
@@ -160,4 +162,8 @@ public interface ILibVipService extends BaseService<LibVip, String> {
 	List<LibVip> findByLibIdActivateTime(String libId,Date signTime);
 	
 	public List<Map<String, Object>> findVipByLibIdMaxActivateTime(String libId,Date activateTime,String species);
+	
+	int countByLibId(String libId);
+	 
+	void updateLibId(String libId);
 }

+ 10 - 0
src/main/java/com/ssj/service/weixin/library/service/impl/LibVipServiceImpl.java

@@ -370,4 +370,14 @@ public class LibVipServiceImpl extends BaseServiceImpl<LibVip, String> implement
 	public List<Map<String, Object>> findVipByLibIdMaxActivateTime(String libId, Date activateTime, String species) {
 		return libVipDao.findVipByLibIdMaxActivateTime(libId, activateTime, species);
 	}
+
+	@Override
+	public int countByLibId(String libId) {
+		return dao.countByLibId(libId);
+	}
+
+	@Override
+	public void updateLibId(String libId) {
+		dao.updateLibId(libId);
+	}
 }

+ 7 - 0
src/main/java/com/ssj/service/weixin/sales/service/LibVipServiceService.java

@@ -634,4 +634,11 @@ public interface LibVipServiceService extends BaseService<LibVipService, String>
 	 * @param vipIdList
 	 */
 	void clearServiceCache(String libId, List<String> vipIdList);
+	
+    /**
+     * 移除校区服务
+     * @param libId
+     * @param num 降级后的服务数量
+     */
+    void removeLibService(String libId,Integer num);
 }

+ 23 - 0
src/main/java/com/ssj/service/weixin/sales/service/impl/LibVipServiceServiceImpl.java

@@ -1683,5 +1683,28 @@ public class LibVipServiceServiceImpl extends BaseServiceImpl<LibVipService, Str
 		});
 	}
 
+	@Override
+	public void removeLibService(String libId, Integer num) {
+		 if (num != null) {
+	            TbLibJoin libJoin = joinService.getById(libId);
+	            if (libJoin != null) {
+	                int studentNum = vipService.countByLibId(libId);
+	                //降级后的学生数大于机构可签约数,直接失效所有
+	                if (studentNum > num) {
+	                    //将馆下所有相关校区服务失效
+	                    libVipServiceDao.clearServiceByLibId(libId);
+	                    //解绑馆下所有学生
+	                    vipService.updateLibId(libId);
+	                }
+	            }
+	        } else {
+	            //将馆下所有相关校区服务失效
+	            libVipServiceDao.clearServiceByLibId(libId);
+	            //解绑馆下所有学生
+	            vipService.updateLibId(libId);
+	        }
+		
+	}
+
 
 }

+ 12 - 3
src/main/java/com/ssj/sys/controller/FxController.java

@@ -1758,7 +1758,7 @@ public class FxController  extends BaseController {
 					String str="";
 					switch (value!=null ?value.toString():"") {
 					case "1":
-						str="直接签约";
+						str="直接签约(旧模式)";
 						break;
 					case "2":
 						str="内部消耗";
@@ -1769,6 +1769,9 @@ public class FxController  extends BaseController {
 					case "4":
 						str="内部不结算(财务)";
 						break;
+					case "5":
+						str="直接签约(新模式)";
+						break;
 					default:
 						str="";
 						break;
@@ -2539,7 +2542,7 @@ public class FxController  extends BaseController {
 						
 						switch (map.get("fm_type")!=null ? map.get("fm_type").toString() : "") {
 							case "1":
-								map.put("fm_type", "直接签约");
+								map.put("fm_type", "直接签约(旧模式)");
 								break;
 							case "2":
 								map.put("fm_type", "内部消耗");
@@ -2550,6 +2553,9 @@ public class FxController  extends BaseController {
 							case "4":
 								map.put("fm_type", "内部不结算(财务)");
 								break;
+							case "5":
+								map.put("fm_type", "直接签约(新模式)");
+								break;
 							default:
 								map.put("fm_type", "");
 								break;
@@ -2557,7 +2563,7 @@ public class FxController  extends BaseController {
 						
 						switch (map.get("tm_type")!=null ? map.get("tm_type").toString() : "") {
 							case "1":
-								map.put("tm_type", "直接签约");
+								map.put("tm_type", "直接签约(旧模式)");
 								break;
 							case "2":
 								map.put("tm_type", "内部消耗");
@@ -2568,6 +2574,9 @@ public class FxController  extends BaseController {
 							case "4":
 								map.put("tm_type", "内部不结算(财务)");
 								break;
+							case "5":
+								map.put("tm_type", "直接签约(新模式)");
+								break;
 							default:
 								map.put("tm_type", "");
 								break;

+ 4 - 2
src/main/resources/templates/sys/fx/consumeList.html

@@ -113,18 +113,20 @@
 					<td th:text="${item.fm_unit_name}"></td>
 					<td th:text="${item.fj_league_name}"></td>
 					<td style="color: red" th:switch="${item.fm_type}">
-					   <span th:case="1">直接签约</span>
+					   <span th:case="1">直接签约(旧模式)</span>
 					   <span th:case="2">内部消耗</span>
 					   <span th:case="3">外部签约</span>
 					   <span th:case="4">内部不结算(财务) </span>
+					   <span th:case="5">直接签约(新模式)</span>
 					</td>
 					<td th:text="${item.tm_unit_name}"></td>
 					<td th:text="${item.tj_league_name}"></td>
 					<td style="color: red" th:switch="${item.tm_type}">
-					   <span th:case="1">直接签约</span>
+					   <span th:case="1">直接签约(旧模式)</span>
 					   <span th:case="2">内部消耗</span>
 					   <span th:case="3">外部签约</span>
 					   <span th:case="4">内部不结算(财务)</span>
+					   <span th:case="5">直接签约(新模式)</span>
 					</td>
 					<td style="color: red" th:switch="${item.type}">
 					   <span th:case="1">充值</span>

+ 4 - 2
src/main/resources/templates/sys/fx/merchantAdd.html

@@ -200,10 +200,11 @@ dtext{
 				<label>商户类型:<b>*</b></label>
 				<div class="vocation" style="margin-right: 5px; width: 345px">
 					<select name="type" id="type" class="select1"> 
-						<option value="1" th:selected="${merchant.type==1 ? true : false}">直接签约</option>
+						<option value="1" th:selected="${merchant.type==1 ? true : false}">直接签约(旧模式)</option>
 						<option value="2" th:selected="${merchant.type==2 ? true : false}">内部消耗</option>
 						<option value="3" th:selected="${merchant.type==3 ? true : false}">外部签约</option>
 						<option value="4" th:selected="${merchant.type==4 ? true : false}">内部不结算(财务)</option>
+						<option value="5" th:selected="${merchant.type==5 ? true : false}">直接签约(新模式)</option>
 					</select>
 				</div>
 			</li>
@@ -212,9 +213,10 @@ dtext{
 				<label>商户类型:<b>*</b></label>
 				<div class="vocation" style="margin-right: 5px; width: 345px">
 					<select name="type" id="type" class="select1"> 
-						<option value="1" th:selected="${merchant.type==1 ? true : false}">直接签约</option>
+						<option value="1" th:selected="${merchant.type==1 ? true : false}">直接签约(旧模式)</option>
 						<option value="2" th:selected="${merchant.type==2 ? true : false}">内部消耗</option>
 						<option value="4" th:selected="${merchant.type==4 ? true : false}">内部不结算(财务)</option>
+						<option value="5" th:selected="${merchant.type==5 ? true : false}">直接签约(新模式)</option>
 					</select>
 				</div>
 			</li>