Переглянути джерело

bug修改,礼品重复领取,积分计算错误。答案借口修改

huan.wang@yueguanjia.com 5 роки тому
батько
коміт
a67b6796e1
22 змінених файлів з 551 додано та 264 видалено
  1. 193 197
      pom.xml
  2. 8 5
      src/main/java/com/ygj/yuemum/controller/college/CollegeUserPointsController.java
  3. 5 0
      src/main/java/com/ygj/yuemum/dao/college/CollegeCurriculumExperienceDao.java
  4. 5 0
      src/main/java/com/ygj/yuemum/dao/college/CollegeCurriculumPracticeDao.java
  5. 1 0
      src/main/java/com/ygj/yuemum/dao/college/CollegeLearningDetailDao.java
  6. 9 0
      src/main/java/com/ygj/yuemum/domain/college/CollegeCurriculumExperience.java
  7. 18 0
      src/main/java/com/ygj/yuemum/domain/college/CollegeCurriculumPractice.java
  8. 9 0
      src/main/java/com/ygj/yuemum/domain/college/CollegePointsDetail.java
  9. 9 0
      src/main/java/com/ygj/yuemum/domain/college/CollegeTest.java
  10. 38 4
      src/main/java/com/ygj/yuemum/service/college/CollegeBookingService.java
  11. 10 0
      src/main/java/com/ygj/yuemum/service/college/CollegeCurriculumExperienceService.java
  12. 11 0
      src/main/java/com/ygj/yuemum/service/college/CollegeCurriculumPracticeService.java
  13. 3 0
      src/main/java/com/ygj/yuemum/service/college/CollegeLearningDetailService.java
  14. 40 22
      src/main/java/com/ygj/yuemum/service/college/CollegeTestService.java
  15. 89 19
      src/main/java/com/ygj/yuemum/service/college/CollegeUserPointsService.java
  16. 17 0
      src/main/java/com/ygj/yuemum/utils/DistanceUtil.java
  17. 33 3
      src/main/resources/mybatis/mapper/college/CollegeCurriculumExperienceMapper.xml
  18. 22 1
      src/main/resources/mybatis/mapper/college/CollegeCurriculumPracticeMapper.xml
  19. 7 0
      src/main/resources/mybatis/mapper/college/CollegeLearningDetailMapper.xml
  20. 10 0
      src/main/resources/mybatis/mapper/college/CollegePointsDetailMapper.xml
  21. 4 8
      src/main/resources/mybatis/mapper/college/CollegePresentRuleMapper.xml
  22. 10 5
      src/main/resources/mybatis/mapper/college/CollegeTestMapper.xml

+ 193 - 197
pom.xml

@@ -1,202 +1,198 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-	<modelVersion>4.0.0</modelVersion>
-	<groupId>com.ygj</groupId>
-	<artifactId>yuemum</artifactId>
-	<version>1</version>
-	<packaging>war</packaging>
-	<name>yuemum</name>
-	<description>Demo project for Spring Boot</description>
-	<!--<profiles>-->
-		<!--<profile>-->
-			<!--<id>dev</id>-->
-			<!--<properties>-->
-				<!--<spring.profiles.active>dev</spring.profiles.active>-->
-			<!--</properties>-->
-			<!--<activation>-->
-				<!--<activeByDefault>true</activeByDefault>-->
-			<!--</activation>-->
-		<!--</profile>-->
-		<!--<profile>-->
-			<!--<id>pro</id>-->
-			<!--<properties>-->
-				<!--<spring.profiles.active>pro</spring.profiles.active>-->
-			<!--</properties>-->
-		<!--</profile>-->
-	<!--</profiles>-->
-
-	<parent>
-		<groupId>org.springframework.boot</groupId>
-		<artifactId>spring-boot-starter-parent</artifactId>
-		<version>1.5.10.RELEASE</version>
-		<relativePath/> <!-- lookup parent from repository -->
-	</parent>
-
-	<properties>
-		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-		<java.version>1.8</java.version>
-	</properties>
-
-	<dependencies>
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-web</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.mybatis.spring.boot</groupId>
-			<artifactId>mybatis-spring-boot-starter</artifactId>
-			<version>1.2.0</version>
-		</dependency>
-
-		<dependency>
-			<groupId>mysql</groupId>
-			<artifactId>mysql-connector-java</artifactId>
-			<scope>runtime</scope>
-		</dependency>
-
-		<dependency>
-			<groupId>com.alibaba</groupId>
-			<artifactId>fastjson</artifactId>
-			<version>1.2.31</version>
-		</dependency>
-		<dependency>
-			<groupId>org.json</groupId>
-			<artifactId>json</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>com.google.code.gson</groupId>
-			<artifactId>gson</artifactId>
-			<version>2.8.2</version>
-		</dependency>
-		<!--启动-->
-		<!--<dependency>-->
-			<!--<groupId>org.springframework.boot</groupId>-->
-			<!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
-			<!--<scope>provided</scope>-->
-		<!--</dependency>-->
-
-
-		<dependency>
-			<groupId>com.fasterxml.jackson.core</groupId>
-			<artifactId>jackson-annotations</artifactId>
-			<version>2.8.0</version>
-		</dependency>
-		<dependency>
-			<groupId>com.fasterxml.jackson.core</groupId>
-			<artifactId>jackson-core</artifactId>
-			<version>2.8.7</version>
-		</dependency>
-		<dependency>
-			<groupId>com.fasterxml.jackson.core</groupId>
-			<artifactId>jackson-databind</artifactId>
-			<version>2.8.7</version>
-		</dependency>
-
-		<dependency>
-			<groupId>com.alibaba</groupId>
-			<artifactId>druid</artifactId>
-			<version>1.1.3</version>
-		</dependency>
-		<!--分页-->
-		<dependency>
-			<groupId>com.github.pagehelper</groupId>
-			<artifactId>pagehelper</artifactId>
-			<version>4.1.6</version>
-		</dependency>
-		<!--emoji-->
-		<dependency>
-			<groupId>com.vdurmont</groupId>
-			<artifactId>emoji-java</artifactId>
-			<version>3.2.0</version>
-		</dependency>
-
-
-		<dependency>
-			<groupId>org.apache.httpcomponents</groupId>
-			<artifactId>httpclient</artifactId>
-			<version>4.5.4</version>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-test</artifactId>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>com.thetransactioncompany</groupId>
-			<artifactId>cors-filter</artifactId>
-			<version>1.7.1</version>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-thymeleaf</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>commons-fileupload</groupId>
-			<artifactId>commons-fileupload</artifactId>
-			<version>1.3.2</version>
-		</dependency>
-		<dependency>
-			<groupId>commons-io</groupId>
-			<artifactId>commons-io</artifactId>
-			<version>2.5</version>
-		</dependency>
-		<dependency>
-			<groupId>commons-lang</groupId>
-			<artifactId>commons-lang</artifactId>
-			<version>2.6</version>
-		</dependency>
-		<!-- Spring 文件上传的依赖包  -->
-		<dependency>
-			<groupId>org.apache.commons</groupId>
-			<artifactId>commons-io</artifactId>
-			<version>1.3.2</version>
-		</dependency>
-		<dependency>
-			<groupId>net.sourceforge.nekohtml</groupId>
-			<artifactId>nekohtml</artifactId>
-			<version>1.9.22</version>
-		</dependency>
-		<dependency>
-			<groupId>org.bouncycastle</groupId>
-			<artifactId>bcprov-jdk15on</artifactId>
-			<version>1.54</version>
-		</dependency>
-		<!--Spring Security-->
-		<!--dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-security</artifactId>
-		</dependency-->
-		<!--Shiro-->
-		<dependency>
-			<groupId>org.apache.shiro</groupId>
-			<artifactId>shiro-spring</artifactId>
-			<version>1.3.2</version>
-		</dependency>
-
-		<!--热部署-->
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-devtools</artifactId>
-			<optional>true</optional>
-		</dependency>
-	</dependencies>
-
-
-	<build>
-		<plugins>
-			<plugin>
-				<groupId>org.springframework.boot</groupId>
-				<artifactId>spring-boot-maven-plugin</artifactId>
-				<configuration>
-					<fork>true</fork>
-				</configuration>
-			</plugin>
-		</plugins>
-	</build>
-
-
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.ygj</groupId>
+    <artifactId>yuemum</artifactId>
+    <version>1</version>
+    <packaging>war</packaging>
+    <name>yuemum</name>
+    <description>Demo project for Spring Boot</description>
+    <!--<profiles>-->
+    <!--<profile>-->
+    <!--<id>dev</id>-->
+    <!--<properties>-->
+    <!--<spring.profiles.active>dev</spring.profiles.active>-->
+    <!--</properties>-->
+    <!--<activation>-->
+    <!--<activeByDefault>true</activeByDefault>-->
+    <!--</activation>-->
+    <!--</profile>-->
+    <!--<profile>-->
+    <!--<id>pro</id>-->
+    <!--<properties>-->
+    <!--<spring.profiles.active>pro</spring.profiles.active>-->
+    <!--</properties>-->
+    <!--</profile>-->
+    <!--</profiles>-->
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>1.5.10.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <java.version>1.8</java.version>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>1.2.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.31</version>
+        </dependency>
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.8.2</version>
+        </dependency>
+        <!--启动-->
+        <!--<dependency>-->
+        <!--<groupId>org.springframework.boot</groupId>-->
+        <!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
+        <!--<scope>provided</scope>-->
+        <!--</dependency>-->
+
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+            <version>2.8.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-core</artifactId>
+            <version>2.8.7</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.8.7</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>1.1.3</version>
+        </dependency>
+        <!--分页-->
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper</artifactId>
+            <version>4.1.6</version>
+        </dependency>
+        <!--emoji-->
+        <dependency>
+            <groupId>com.vdurmont</groupId>
+            <artifactId>emoji-java</artifactId>
+            <version>3.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.thetransactioncompany</groupId>
+            <artifactId>cors-filter</artifactId>
+            <version>1.7.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-thymeleaf</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-fileupload</groupId>
+            <artifactId>commons-fileupload</artifactId>
+            <version>1.3.2</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.5</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.6</version>
+        </dependency>
+        <!-- Spring 文件上传的依赖包  -->
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>1.3.2</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sourceforge.nekohtml</groupId>
+            <artifactId>nekohtml</artifactId>
+            <version>1.9.22</version>
+        </dependency>
+        <dependency>
+            <groupId>org.bouncycastle</groupId>
+            <artifactId>bcprov-jdk15on</artifactId>
+            <version>1.54</version>
+        </dependency>
+        <!--Spring Security-->
+        <!--dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-security</artifactId>
+        </dependency-->
+        <!--Shiro-->
+        <dependency>
+            <groupId>org.apache.shiro</groupId>
+            <artifactId>shiro-spring</artifactId>
+            <version>1.3.2</version>
+        </dependency>
+
+        <!--热部署-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-devtools</artifactId>
+            <optional>true</optional>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <fork>true</fork>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 
 
 </project>

+ 8 - 5
src/main/java/com/ygj/yuemum/controller/college/CollegeUserPointsController.java

@@ -5,14 +5,11 @@ import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.ygj.yuemum.domain.college.CollegeUserPoints;
 import com.ygj.yuemum.service.college.CollegeUserPointsService;
-import com.ygj.yuemum.service.wxmini.WXContentService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Map;
 
 @RestController
 public class CollegeUserPointsController {
@@ -44,10 +41,16 @@ public class CollegeUserPointsController {
     public int updateCollegeUserPoints(@ModelAttribute CollegeUserPoints collegeUserPoints) {
         return collegeUserPointsService.updateCollegeUserPoints(collegeUserPoints);
     }
+
     @PostMapping("/college/queryUserPoints")
-    public String QueryUserPoints(@RequestParam("openid") String openid,@RequestParam("city") String city) {
-        LinkedHashMap<String, Object> orderTemps = collegeUserPointsService.QueryUserPoints(openid,city);
+    public String QueryUserPoints(@RequestParam("openid") String openid, @RequestParam("city") String city) {
+        LinkedHashMap<String, Object> orderTemps = collegeUserPointsService.QueryUserPoints(openid, city);
         String jso = JSONObject.toJSONString(orderTemps, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue);
         return jso;
     }
+
+    @PostMapping("/college/getPointsByOffline")
+    public int getPointsByOffline(@RequestParam("openid") String openid, @RequestParam("c_code") String c_code, @RequestParam("lat") String lat, @RequestParam("lon") String lon) {
+        return collegeUserPointsService.getPointsByOffline(openid, c_code, lat, lon);
+    }
 }

+ 5 - 0
src/main/java/com/ygj/yuemum/dao/college/CollegeCurriculumExperienceDao.java

@@ -26,5 +26,10 @@ public interface CollegeCurriculumExperienceDao {
 
     CollegeCurriculumExperience queryExperienceDetail(CollegeQuery collegePracticeQuery);
 
+    CollegeCurriculumExperience getExperienceByCode(String c_code);
+
+    int updatePCountAdd(String c_code);
+    int updatePCountCancel(String c_code);
+
 
 }

+ 5 - 0
src/main/java/com/ygj/yuemum/dao/college/CollegeCurriculumPracticeDao.java

@@ -1,5 +1,6 @@
 package com.ygj.yuemum.dao.college;
 
+import com.ygj.yuemum.domain.college.CollegeCurriculumExperience;
 import com.ygj.yuemum.domain.college.CollegeCurriculumPractice;
 import com.ygj.yuemum.domain.college.CollegeCurriculumQuery;
 import com.ygj.yuemum.domain.college.CollegeQuery;
@@ -24,6 +25,10 @@ public interface CollegeCurriculumPracticeDao {
 
     List<CollegeCurriculumPractice> queryUserLearningPractice(CollegeCurriculumQuery collegeCurriculumQuery);
     CollegeCurriculumPractice queryPracticeDetail(CollegeQuery collegePracticeQuery);
+    CollegeCurriculumPractice getPracticeByCode(String c_code);
+
+    int updatePCountAdd(String c_code);
+    int updatePCountCancel(String c_code);
 
 
 }

+ 1 - 0
src/main/java/com/ygj/yuemum/dao/college/CollegeLearningDetailDao.java

@@ -18,6 +18,7 @@ public interface CollegeLearningDetailDao {
 
     int updateByPrimaryKeySelective(CollegeLearningDetail record);
 
+    int deleteBookingCancel(CollegeLearningDetail collegeLearningDetail);
 
     CollegeLearningDetail checkCorePositive(CollegeLearningDetail collegeLearningDetail);
 

+ 9 - 0
src/main/java/com/ygj/yuemum/domain/college/CollegeCurriculumExperience.java

@@ -21,10 +21,19 @@ public class CollegeCurriculumExperience {
     private Integer bookingid;
     private String learningStatus;
     private String openid;
+    private Integer pcount;
     private Integer page;
     private Integer limit;
     private String img_href;
 
+    public Integer getPcount() {
+        return pcount;
+    }
+
+    public void setPcount(Integer pcount) {
+        this.pcount = pcount;
+    }
+
     public String getOpenid() {
         return openid;
     }

+ 18 - 0
src/main/java/com/ygj/yuemum/domain/college/CollegeCurriculumPractice.java

@@ -23,11 +23,29 @@ public class CollegeCurriculumPractice {
     private String qrcode;
     private Integer page;
     private Integer bookingid;
+    private String mi_latitude;
+    private String mi_longitude;
     private String openid;
     private String learningStatus;
     private Integer limit;
     private String img_href;
 
+    public String getMi_latitude() {
+        return mi_latitude;
+    }
+
+    public void setMi_latitude(String mi_latitude) {
+        this.mi_latitude = mi_latitude;
+    }
+
+    public String getMi_longitude() {
+        return mi_longitude;
+    }
+
+    public void setMi_longitude(String mi_longitude) {
+        this.mi_longitude = mi_longitude;
+    }
+
     public String getOpenid() {
         return openid;
     }

+ 9 - 0
src/main/java/com/ygj/yuemum/domain/college/CollegePointsDetail.java

@@ -5,12 +5,21 @@ public class CollegePointsDetail {
     private Integer id;
     private String openid;
     private Integer event_code;
+    private Integer rule_id;
     private String context;
     private Integer credit;
     private String date;
     private Integer page;
     private Integer limit;
 
+    public Integer getRule_id() {
+        return rule_id;
+    }
+
+    public void setRule_id(Integer rule_id) {
+        this.rule_id = rule_id;
+    }
+
     public Integer getId() {
         return id;
     }

+ 9 - 0
src/main/java/com/ygj/yuemum/domain/college/CollegeTest.java

@@ -12,8 +12,17 @@ public class CollegeTest {
     private List<CollegeTestResult> collegeTestResults;
     private String comment;
     private String userAnswer;
+    private Integer rightSeq;
     private boolean result;
 
+    public Integer getRightSeq() {
+        return rightSeq;
+    }
+
+    public void setRightSeq(Integer rightSeq) {
+        this.rightSeq = rightSeq;
+    }
+
     public boolean isResult() {
         return result;
     }

+ 38 - 4
src/main/java/com/ygj/yuemum/service/college/CollegeBookingService.java

@@ -2,9 +2,7 @@ package com.ygj.yuemum.service.college;
 
 import com.ygj.yuemum.dao.college.CollegeBookingDao;
 import com.ygj.yuemum.dao.college.CollegeTestDao;
-import com.ygj.yuemum.domain.college.CollegeBooking;
-import com.ygj.yuemum.domain.college.CollegeLearningDetail;
-import com.ygj.yuemum.domain.college.CollegeTest;
+import com.ygj.yuemum.domain.college.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -19,11 +17,18 @@ public class CollegeBookingService {
     private CollegeBookingDao collegeBookingDao;
     @Autowired
     private CollegeLearningDetailService collegeLearningDetailService;
+    @Autowired
+    private CollegeCurriculumPracticeService collegeCurriculumPracticeService;
+    @Autowired
+    private CollegeCurriculumExperienceService collegeCurriculumExperienceService;
 
     public List<CollegeBooking> getCollegeBookings() {
         List<CollegeBooking> collegeBookings = collegeBookingDao.getAll();
         return collegeBookings;
     }
+    public CollegeBooking checkBooking(CollegeBooking collegeBooking){
+        return collegeBookingDao.checkBooking(collegeBooking);
+    }
 
     public CollegeBooking getCollegeBooking(Integer id) {
         return collegeBookingDao.selectByPrimaryKey(id);
@@ -46,6 +51,14 @@ public class CollegeBookingService {
                 collegeLearningDetail.setStatus(1);
                 collegeLearningDetailService.addCollegeLearningDetail(collegeLearningDetail);
                 collegeBookingDao.insertSelective(collegeBooking);
+                // pcount
+                if(collegeBooking.getCollege_code().substring(0,1).equals("P")){
+                    collegeCurriculumPracticeService.updatePCountAdd(collegeBooking.getCollege_code());
+                }
+                if(collegeBooking.getCollege_code().substring(0,1).equals("E")){
+                    collegeCurriculumExperienceService.updatePCountAdd(collegeBooking.getCollege_code());
+                }
+
                 return 1;
             }catch (Exception ex){
                 ex.printStackTrace();
@@ -64,7 +77,28 @@ public class CollegeBookingService {
     }
 
     public int bookingCancel(CollegeBooking collegeBooking) {
-        return collegeBookingDao.bookingCancel(collegeBooking);
+        try {
+            CollegeBooking collegeBooking1 = collegeBookingDao.checkBooking(collegeBooking);
+            if( collegeBooking1 == null) {
+                return  0;
+            }
+            collegeBookingDao.bookingCancel(collegeBooking);
+            CollegeLearningDetail collegeLearningDetail = new CollegeLearningDetail();
+            collegeLearningDetail.setOpen_id(collegeBooking.getOpenid());
+            collegeLearningDetail.setC_code(collegeBooking.getCollege_code());
+            collegeLearningDetailService.deleteBookingCancel(collegeLearningDetail);
+            //pcount
+            if(collegeBooking.getCollege_code().substring(0,1).equals("P")){
+                collegeCurriculumPracticeService.updatePCountCancel(collegeBooking.getCollege_code());
+            }
+            if(collegeBooking.getCollege_code().substring(0,1).equals("E")){
+                collegeCurriculumExperienceService.updatePCountCancel(collegeBooking.getCollege_code());
+            }
+            return 1;
+        }catch (Exception ex) {
+            ex.printStackTrace();
+            return 0;
+        }
     }
 
 }

+ 10 - 0
src/main/java/com/ygj/yuemum/service/college/CollegeCurriculumExperienceService.java

@@ -131,5 +131,15 @@ public class CollegeCurriculumExperienceService {
             return null;
         }
     }
+    public CollegeCurriculumExperience getExperienceByCode(String c_code) {
+        return collegeCurriculumExperienceDao.getExperienceByCode(c_code);
+    }
+
+    public int updatePCountAdd(String c_code){
+        return collegeCurriculumExperienceDao.updatePCountAdd(c_code);
+    }
 
+    public int updatePCountCancel(String c_code){
+        return collegeCurriculumExperienceDao.updatePCountCancel(c_code);
+    }
 }

+ 11 - 0
src/main/java/com/ygj/yuemum/service/college/CollegeCurriculumPracticeService.java

@@ -143,5 +143,16 @@ public class CollegeCurriculumPracticeService {
             return null;
         }
     }
+    public CollegeCurriculumPractice getPracticeByCode(String c_code) {
+        return collegeCurriculumPracticeDao.getPracticeByCode(c_code);
+    }
+
+    public int updatePCountAdd(String c_code){
+        return collegeCurriculumPracticeDao.updatePCountAdd(c_code);
+    }
+
+    public int updatePCountCancel(String c_code){
+        return collegeCurriculumPracticeDao.updatePCountCancel(c_code);
+    }
 
 }

+ 3 - 0
src/main/java/com/ygj/yuemum/service/college/CollegeLearningDetailService.java

@@ -32,6 +32,9 @@ public class CollegeLearningDetailService {
     public int deleteCollegeLearningDetail(Integer id) {
         return collegeLearningDetailDao.deleteByPrimaryKey(id);
     }
+    public int deleteBookingCancel(CollegeLearningDetail collegeLearningDetail) {
+        return collegeLearningDetailDao.deleteBookingCancel(collegeLearningDetail);
+    }
 
     public int updateCollegeLearningDetail(CollegeLearningDetail collegeLearningDetail) {
         return collegeLearningDetailDao.updateByPrimaryKeySelective(collegeLearningDetail);

+ 40 - 22
src/main/java/com/ygj/yuemum/service/college/CollegeTestService.java

@@ -54,35 +54,53 @@ public class CollegeTestService {
         collegeTestDetailQuery.setCoreid(core_id);
         collegeTestDetailQuery.setOpenid(openid);
         String[] answers = null;
-        CollegeTestDetail collegeTestDetail = collegeTestDetailService.queryUserAnswers(collegeTestDetailQuery);
         List<CollegeTest> collegeTestsReturn = new LinkedList<CollegeTest>();
         List<CollegeTest> collegeTests = collegeTestDao.selectByCoreId(core_id);
-        answers = collegeTestDetail.getAnswers().split(",");
-        int i = 0;
-        for (CollegeTest collegeTest: collegeTests) {
-            CollegeTest collegeTestTemp = new CollegeTest();
-            List<CollegeTestResult> collegeTestResults = collegeTestResultService.selectByTestId(collegeTest.getId());
-            for(CollegeTestResult collegeTestResult:collegeTestResults){
-                if(collegeTestResult.isIsright()&&answers[i].equals(String.valueOf(collegeTestResult.getSeq()))){
-                    collegeTestTemp.setResult(true);
-                    break;
-                } else {
-                    collegeTestTemp.setResult(false);
+        CollegeTestDetail collegeTestDetail = collegeTestDetailService.queryUserAnswers(collegeTestDetailQuery);
+        if(collegeTestDetail == null) {
+            for (CollegeTest collegeTest: collegeTests) {
+                CollegeTest collegeTestTemp = new CollegeTest();
+                List<CollegeTestResult> collegeTestResults = collegeTestResultService.selectByTestId(collegeTest.getId());
+                collegeTestTemp.setId(collegeTest.getId());
+                collegeTestTemp.setSeq(collegeTest.getSeq());
+                collegeTestTemp.setName(collegeTest.getName());
+                collegeTestTemp.setDesc(collegeTest.getDesc());
+                collegeTestTemp.setScore(collegeTest.getScore());
+                collegeTestTemp.setCollegeTestResults(collegeTestResults);
+                collegeTestTemp.setComment(collegeTest.getComment());
+                collegeTestsReturn.add(collegeTestTemp);
+            }
+        }else {
+            answers = collegeTestDetail.getAnswers().split(",");
+            int i = 0;
+
+            for (CollegeTest collegeTest: collegeTests) {
+                CollegeTest collegeTestTemp = new CollegeTest();
+                List<CollegeTestResult> collegeTestResults = collegeTestResultService.selectByTestId(collegeTest.getId());
+                for(CollegeTestResult collegeTestResult:collegeTestResults){
+                    if(collegeTestResult.isIsright()&&answers[i].equals(String.valueOf(collegeTestResult.getSeq()))){
+                        collegeTestTemp.setResult(true);
+                        break;
+                    } else {
+                        collegeTestTemp.setResult(false);
+                    }
                 }
+                collegeTestTemp.setId(collegeTest.getId());
+                collegeTestTemp.setSeq(collegeTest.getSeq());
+                collegeTestTemp.setName(collegeTest.getName());
+                collegeTestTemp.setDesc(collegeTest.getDesc());
+                collegeTestTemp.setScore(collegeTest.getScore());
+                collegeTestTemp.setCollegeTestResults(collegeTestResults);
+                collegeTestTemp.setComment(collegeTest.getComment());
+                collegeTestTemp.setUserAnswer(answers[i]);
+                collegeTestTemp.setRightSeq(collegeTest.getRightSeq());
+                i++;
+                collegeTestsReturn.add(collegeTestTemp);
             }
-            collegeTestTemp.setId(collegeTest.getId());
-            collegeTestTemp.setSeq(collegeTest.getSeq());
-            collegeTestTemp.setName(collegeTest.getName());
-            collegeTestTemp.setDesc(collegeTest.getDesc());
-            collegeTestTemp.setScore(collegeTest.getScore());
-            collegeTestTemp.setCollegeTestResults(collegeTestResults);
-            collegeTestTemp.setComment(collegeTest.getComment());
-            collegeTestTemp.setUserAnswer(answers[i]);
-            i++;
-            collegeTestsReturn.add(collegeTestTemp);
         }
 
 
+
         return collegeTestsReturn;
     }
 

+ 89 - 19
src/main/java/com/ygj/yuemum/service/college/CollegeUserPointsService.java

@@ -12,6 +12,7 @@ import com.ygj.yuemum.service.wxmini.WXUserService;
 import com.ygj.yuemum.utils.DateUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import com.ygj.yuemum.utils.DistanceUtil;
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -41,7 +42,10 @@ public class CollegeUserPointsService {
     private WeChatInfoController weChatInfoController;
     @Autowired
     private CouponCreateService couponCreateService;
-
+    @Autowired
+    private CollegeBookingService collegeBookingService;
+    @Autowired
+    private CollegeLearningDetailService collegeLearningDetailService;
 
 
     public Integer LMP = Constant.LMP;
@@ -68,19 +72,21 @@ public class CollegeUserPointsService {
     public int updateCollegeUserPoints(CollegeUserPoints collegeUserPoints) {
         return collegeUserPointsDao.updateByPrimaryKeySelective(collegeUserPoints);
     }
+
     public int updatePointsByTest(String openid) {
         return collegeUserPointsDao.updatePointsByTest(openid);
     }
+
     public CollegeUserPoints queryOneUserPoints(String openid) {
         return collegeUserPointsDao.queryOneUserPoints(openid);
     }
 
-    public LinkedHashMap<String, Object> QueryUserPoints(String openid,String city) {
+    public LinkedHashMap<String, Object> QueryUserPoints(String openid, String city) {
         LinkedHashMap<String, Object> tableData = new LinkedHashMap<>();
         WXUser wxUser = wxUserService.getWXUser(openid);
         tableData.put("stage", null);
         tableData.put("stage_date", null);
-        if (wxUser != null  && wxUser.getXu_phone() != null) {
+        if (wxUser != null && wxUser.getXu_phone() != null) {
             if (wxUser.getXu_content_type() != null && wxUser.getXu_content_date() != null) {
                 try {
                     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
@@ -92,11 +98,11 @@ public class CollegeUserPointsService {
                     CollegeCurriculumExperience collegeCurriculumExperienceQuery = new CollegeCurriculumExperience();
                     CollegePointsDetail collegePointsDetail = new CollegePointsDetail();
                     if (wxUser.getXu_content_type().equals("B01")) { //育儿
-                        if(dateNow.getTime() < getDate.getTime()) {
+                        if (dateNow.getTime() < getDate.getTime()) {
                             //还没出生
                             return tableData;
                         } else {
-                            if(DateUtil.getMonthDiff(dateNow, getDate) + 1 > AGE) {
+                            if (DateUtil.getMonthDiff(dateNow, getDate) + 1 > AGE) {
                                 return tableData;
                             } else {
                                 tableData.put("stage_step", DateUtil.getMonthDiff(dateNow, getDate) + 1);
@@ -109,8 +115,8 @@ public class CollegeUserPointsService {
                             }
                         }
                     } else if (wxUser.getXu_content_type().equals("P01")) { //孕周
-                        if(dateNow.getTime() < getDate.getTime()) {
-                            if (LMP-DateUtil.getWeekDiff(dateNow, getDate) < 0) {
+                        if (dateNow.getTime() < getDate.getTime()) {
+                            if (LMP - DateUtil.getWeekDiff(dateNow, getDate) < 0) {
                                 return tableData; //还没怀孕
                             } else {
                                 tableData.put("stage_step", DateUtil.getWeekDiff(dateNow, getDate));
@@ -121,7 +127,7 @@ public class CollegeUserPointsService {
                                 collegeCurriculumExperienceQuery.setC_type("P01");
                                 collegeCurriculumExperienceQuery.setC_step(DateUtil.getWeekDiff(dateNow, getDate));
                             }
-                        }else {
+                        } else {
                             return tableData;
                         }
                     } else {
@@ -129,7 +135,7 @@ public class CollegeUserPointsService {
                     }
                     tableData.put("stage", wxUser.getXu_content_type());
                     tableData.put("stage_date", wxUser.getXu_content_date());
-                    tableData.put("avatar_url",wxUser.getXu_avatarUrl());
+                    tableData.put("avatar_url", wxUser.getXu_avatarUrl());
                     //查询学分
                     int point_available = 0;
                     CollegeUserPoints collegeUserPoints = collegeUserPointsDao.queryOneUserPoints(openid);
@@ -145,9 +151,9 @@ public class CollegeUserPointsService {
                         point_available = collegeUserPoints.getCredit_available();
                     }
                     //礼品领取情况
-                    List<CollegePresentRule> collegePresentRules =  collegePresentRuleService.queryUserReceived(openid);
-                    for(CollegePresentRule collegePresentRule:collegePresentRules) {
-                        if(collegePresentRule.getReceived() != 1 && point_available >= collegePresentRule.getValue()) {
+                    List<CollegePresentRule> collegePresentRules = collegePresentRuleService.queryUserReceived(openid);
+                    for (CollegePresentRule collegePresentRule : collegePresentRules) {
+                        if (collegePresentRule.getReceived() != 1 && point_available >= collegePresentRule.getValue()) {
                             //返回礼品内容
                             tableData.put("surprise", "true");
                             tableData.put("surprise_type", collegePresentRule.getType());
@@ -165,17 +171,18 @@ public class CollegeUserPointsService {
                                 weChatInfoController.WXSendBookingMessage(customerBooking);
                                 collegePointsDetail.setContext(collegePresentRule.getPresent_name());
                             } else {
-                                //优惠券领取接口  ???
-                                String cb_code = couponCreateService.couponIssue(collegePresentRule.getCoupon_cid(),wxUser.getXu_phone());
-                                collegePointsDetail.setContext(collegePresentRule.getPresent_name()+":"+cb_code);
+                                //优惠券领取接口
+                                String cb_code = couponCreateService.couponIssue(collegePresentRule.getCoupon_cid(), wxUser.getXu_phone());
+                                collegePointsDetail.setContext(collegePresentRule.getPresent_name() + ":" + cb_code);
                             }
                             //保存领取日志
                             collegePointsDetail.setOpenid(openid);
                             collegePointsDetail.setDate(ldf.format(new Date()));
                             collegePointsDetail.setEvent_code(4);
                             collegePointsDetail.setCredit(collegePresentRule.getValue() * -1);
+                            collegePointsDetail.setRule_id(collegePresentRule.getId());
                             collegePointsDetailService.addCollegePointsDetail(collegePointsDetail);
-                            //更新学分
+                            //更新学分  ????
                             collegeUserPoints.setCredit_available(collegeUserPoints.getCredit_available() - collegePresentRule.getValue());
                             collegeUserPointsDao.updateByPrimaryKeySelective(collegeUserPoints);
                             break;
@@ -184,17 +191,17 @@ public class CollegeUserPointsService {
                     tableData.put("present_received", collegePresentRules);
                     //常规课
                     List<CollegeCurriculumCore> collegeCurriculumCores = collegeCurriculumCoreService.queryCoreByStep(collegeCurriculumCoreQuery);
-                    tableData.put("college_core",collegeCurriculumCores);
+                    tableData.put("college_core", collegeCurriculumCores);
                     //实践课
                     collegeCurriculumPracticeQuery.setDeadline(sdf.format(new Date()));
                     collegeCurriculumPracticeQuery.setCity(city);
                     collegeCurriculumPracticeQuery.setStartdate(sdf.format(new Date()));
                     List<CollegeCurriculumPractice> collegeCurriculumPractices = collegeCurriculumPracticeService.queryPracticeByStep(collegeCurriculumPracticeQuery);
-                    tableData.put("college_practice",collegeCurriculumPractices);
+                    tableData.put("college_practice", collegeCurriculumPractices);
                     //体验课
                     collegeCurriculumExperienceQuery.setCity(city);
                     List<CollegeCurriculumExperience> collegeCurriculumExperiences = collegeCurriculumExperienceService.queryExperienceByStep(collegeCurriculumExperienceQuery);
-                    tableData.put("college_experience",collegeCurriculumExperiences);
+                    tableData.put("college_experience", collegeCurriculumExperiences);
                     return tableData;
                 } catch (Exception ex) {
                     ex.printStackTrace();
@@ -210,4 +217,67 @@ public class CollegeUserPointsService {
         }
     }
 
+    public int getPointsByOffline(String openid, String c_code, String lat, String lon) {
+        //51-参数错误 52-没有预约 53-不在范围 54-已完成
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        if (c_code.indexOf("College") == -1) {
+            return 51; //参数错误
+        }
+        CollegeBooking collegeBooking = new CollegeBooking();
+        collegeBooking.setOpenid(openid);
+        collegeBooking.setCollege_code(c_code.substring(8, c_code.length()));
+        String lat_l, lon_l;
+        int credit = 0;
+        if (collegeBookingService.checkBooking(collegeBooking) != null) {
+            if (c_code.substring(7, 1) == "P") {
+                CollegeCurriculumPractice collegeCurriculumPractice = collegeCurriculumPracticeService.getPracticeByCode(c_code);
+                lat_l = collegeCurriculumPractice.getMi_latitude();
+                lon_l = collegeCurriculumPractice.getMi_longitude();
+                credit = collegeCurriculumPractice.getCredit();
+            } else if (c_code.substring(7, 1) == "E") {
+                CollegeCurriculumExperience collegeCurriculumExperience = collegeCurriculumExperienceService.getExperienceByCode(c_code.substring(8, c_code.length()));
+                lat_l = collegeCurriculumExperience.getLatitude();
+                lon_l = collegeCurriculumExperience.getLongitude();
+                credit = collegeCurriculumExperience.getCredit();
+            } else {
+                return 51; //参数错误
+            }
+            DistanceUtil distanceUtil = new DistanceUtil();
+            double distance = distanceUtil.GetDistance(Double.parseDouble(lat_l), Double.parseDouble(lon_l), Double.parseDouble(lat), Double.parseDouble(lon));
+            if (distance > 500) {
+                return 53; //不在范围内
+            } else {
+                //判断是否已完成
+                CollegeLearningDetail collegeLearningDetail = new CollegeLearningDetail();
+                collegeLearningDetail.setOpen_id(openid);
+                collegeLearningDetail.setC_code(c_code.substring(8, c_code.length()));
+                CollegeLearningDetail collegeLearningDetailC  = collegeLearningDetailService.checkCorePositive(collegeLearningDetail);
+                if (collegeLearningDetailC.getStatus() != 9) {
+                    collegeLearningDetailC.setDate(sdf.format(new Date()));
+                    collegeLearningDetailC.setStatus(9);
+                    collegeLearningDetailC.setCredit(credit);
+                    collegeLearningDetailService.addCollegeLearningDetail(collegeLearningDetailC);
+                } else {
+                    return 54; //已完成
+                }
+                //判断是否已经学习 增加学分
+                CollegeUserPoints collegeUserPoints = collegeUserPointsDao.queryOneUserPoints(openid);
+                if(collegeUserPoints == null) {
+                    CollegeUserPoints collegeUserPointsNew = new CollegeUserPoints();
+                    collegeUserPointsNew.setOpenid(openid);
+                    collegeUserPointsNew.setCredit_total(credit);
+                    collegeUserPointsNew.setCredit_available(credit);
+                } else {
+                    CollegeUserPoints collegeUserPointsNew = new CollegeUserPoints();
+                    collegeUserPointsNew.setOpenid(openid);
+                    collegeUserPointsNew.setCredit_total(collegeUserPoints.getCredit_total() + credit);
+                    collegeUserPointsNew.setCredit_available(collegeUserPoints.getCredit_available() + credit);
+                }
+                return 1;
+            }
+        } else {
+            return 52; //没有预约
+        }
+    }
+
 }

+ 17 - 0
src/main/java/com/ygj/yuemum/utils/DistanceUtil.java

@@ -0,0 +1,17 @@
+package com.ygj.yuemum.utils;
+
+public class DistanceUtil {
+    private static final  double EARTH_RADIUS = 6378137;//赤道半径
+    private static double rad(double d){
+        return d * Math.PI / 180.0;
+    }
+    public static double GetDistance(double lon1,double lat1,double lon2, double lat2) {
+        double radLat1 = rad(lat1);
+        double radLat2 = rad(lat2);
+        double a = radLat1 - radLat2;
+        double b = rad(lon1) - rad(lon2);
+        double s = 2 *Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2)+Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
+        s = s * EARTH_RADIUS;
+        return s;//单位米
+    }
+}

+ 33 - 3
src/main/resources/mybatis/mapper/college/CollegeCurriculumExperienceMapper.xml

@@ -19,6 +19,7 @@
         <result column="credit" property="credit" jdbcType="INTEGER" />
         <result column="qrcode" property="qrcode" jdbcType="VARCHAR" />
         <result column="img_href" property="img_href" jdbcType="VARCHAR" />
+        <result column="pcount" property="pcount" jdbcType="INTEGER" />
     </resultMap>
     <!--获取所有数据-->
 
@@ -29,6 +30,15 @@
         order by id desc
     </select>
 
+
+    <select id="getExperienceByCode" resultType="com.ygj.yuemum.domain.college.CollegeCurriculumExperience" parameterType="java.lang.String" >
+        select
+        *
+        from college_curriculum_experience
+        where c_code = #{c_code,jdbcType=VARCHAR}
+        order by id desc
+    </select>
+
     <select id="queryExperienceByStep" resultType="com.ygj.yuemum.domain.college.CollegeCurriculumExperience" parameterType="com.ygj.yuemum.domain.college.CollegeCurriculumExperience">
         select
         cce.*,
@@ -118,7 +128,10 @@
                 qrcode,
             </if>
             <if test="img_href != null" >
-                img_href
+                img_href,
+            </if>
+            <if test="pcount != null" >
+                pcount
             </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides="," >
@@ -165,7 +178,10 @@
                 #{qrcode,jdbcType=VARCHAR},
             </if>
             <if test="img_href != null" >
-                #{img_href,jdbcType=VARCHAR}
+                #{img_href,jdbcType=VARCHAR},
+            </if>
+            <if test="pcount != null" >
+                #{pcount,jdbcType=INTEGER}
             </if>
         </trim>
     </insert>
@@ -239,10 +255,24 @@
                 qrcode = #{qrcode,jdbcType=VARCHAR},
             </if>
             <if test="img_href != null" >
-                img_href = #{img_href,jdbcType=VARCHAR}
+                img_href = #{img_href,jdbcType=VARCHAR},
+            </if>
+            <if test="pcount != null" >
+                pcount = #{pcount,jdbcType=INTEGER}
             </if>
         </set>
         where id = #{id,jdbcType=INTEGER}
     </update>
 
+
+    <update id="updatePCountAdd" parameterType="java.lang.String">
+        update college_curriculum_experience set pcount = pcount +1
+        where c_code =  #{c_code,jdbcType=VARCHAR}
+    </update>
+
+    <update id="updatePCountCancel" parameterType="java.lang.String">
+        update college_curriculum_experience set pcount = pcount  - 1
+        where c_code =  #{c_code,jdbcType=VARCHAR}
+    </update>
+
 </mapper>

+ 22 - 1
src/main/resources/mybatis/mapper/college/CollegeCurriculumPracticeMapper.xml

@@ -32,6 +32,16 @@
         order by id desc
     </select>
 
+
+    <select id="getPracticeByCode" resultType="com.ygj.yuemum.domain.college.CollegeCurriculumPractice" parameterType="java.lang.String" >
+        select  college_curriculum_practice.*,
+        wx_mkt_info.mi_latitude,
+        wx_mkt_info.mi_longitude
+        from college_curriculum_practice LEFT JOIN wx_mkt_info ON college_curriculum_practice.branches = wx_mkt_info.id
+        where c_code = #{c_code,jdbcType=VARCHAR}
+        order by id desc
+    </select>
+
     <select id="queryUserLearningPractice" resultType="com.ygj.yuemum.domain.college.CollegeCurriculumPractice" parameterType="com.ygj.yuemum.domain.college.CollegeCurriculumQuery">
         SELECT
         cc.*,
@@ -91,7 +101,7 @@
     <select id="queryPracticeDetail" resultType="com.ygj.yuemum.domain.college.CollegeCurriculumPractice" parameterType="com.ygj.yuemum.domain.college.CollegeQuery" >
         SELECT
             ccp.* ,
-            (select id from college_booking where phone = #{phone,jdbcType=VARCHAR} and college_code = ccp.c_code ) bookingid,
+            (select id from college_booking where phone = #{phone,jdbcType=VARCHAR}  and openid =  #{openid,jdbcType=VARCHAR} and college_code = ccp.c_code ) bookingid,
             (select status from college_learning_detail where open_id =  #{openid,jdbcType=VARCHAR} and college_learning_detail.c_code  = ccp.c_code order by id desc limit 1 ) learningStatus
         FROM
             college_curriculum_practice  ccp
@@ -282,4 +292,15 @@
         where id = #{id,jdbcType=INTEGER}
     </update>
 
+
+    <update id="updatePCountAdd" parameterType="java.lang.String">
+        update college_curriculum_practice set pcount = pcount +1
+        where c_code =  #{c_code,jdbcType=VARCHAR}
+    </update>
+
+    <update id="updatePCountCancel" parameterType="java.lang.String">
+        update college_curriculum_practice set pcount = pcount  - 1
+        where c_code =  #{c_code,jdbcType=VARCHAR}
+    </update>
+
 </mapper>

+ 7 - 0
src/main/resources/mybatis/mapper/college/CollegeLearningDetailMapper.xml

@@ -48,10 +48,17 @@
 
 
     <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
+
         delete from college_learning_detail
         where id = #{id,jdbcType=INTEGER}
     </delete>
 
+    <delete id="deleteBookingCancel" parameterType="com.ygj.yuemum.domain.college.CollegeLearningDetail" >
+        delete from college_learning_detail
+        where open_id = #{open_id,jdbcType=INTEGER}
+        and c_code = #{c_code,jdbcType=INTEGER}
+    </delete>
+
     <insert id="insertSelective" parameterType="com.ygj.yuemum.domain.college.CollegeLearningDetail" >
         insert into college_learning_detail
         <trim prefix="(" suffix=")" suffixOverrides="," >

+ 10 - 0
src/main/resources/mybatis/mapper/college/CollegePointsDetailMapper.xml

@@ -6,6 +6,7 @@
         <id column="id" property="id" jdbcType="INTEGER" />
         <result column="openid" property="openid" jdbcType="VARCHAR" />
         <result column="event_code" property="event_code" jdbcType="INTEGER" />
+        <result column="rule_id" property="rule_id" jdbcType="INTEGER" />
         <result column="context" property="context" jdbcType="VARCHAR" />
         <result column="credit" property="credit" jdbcType="INTEGER" />
         <result column="date" property="date" jdbcType="VARCHAR" />
@@ -41,6 +42,9 @@
             <if test="event_code != null" >
                 event_code,
             </if>
+            <if test="rule_id != null" >
+                rule_id,
+            </if>
             <if test="context != null" >
                 context,
             </if>
@@ -58,6 +62,9 @@
             <if test="event_code != null" >
                 #{event_code,jdbcType=INTEGER},
             </if>
+            <if test="rule_id != null" >
+                #{rule_id,jdbcType=VARCHAR},
+            </if>
             <if test="context != null" >
                 #{context,jdbcType=VARCHAR},
             </if>
@@ -79,6 +86,9 @@
             <if test="event_code != null" >
                 event_code = #{event_num,jdbcType=INTEGER},
             </if>
+            <if test="rule_id != null" >
+                rule_id = #{rule_id,jdbcType=VARCHAR},
+            </if>
             <if test="context != null" >
                 context = #{context,jdbcType=VARCHAR},
             </if>

+ 4 - 8
src/main/resources/mybatis/mapper/college/CollegePresentRuleMapper.xml

@@ -22,15 +22,11 @@
 
 
     <select id="queryUserReceived" resultType="com.ygj.yuemum.domain.college.CollegePresentRule" parameterType="java.lang.String">
-        SELECT
-	college_present_rule.*,
-    IF
-	    ( tt.context > 0, 1, 0 ) as received
+	SELECT
+        cpr.*,
+        if ((SELECT id FROM college_points_detail WHERE openid = #{openid,jdbcType=VARCHAR} and event_code = 4 and  rule_id = cpr.id) >= 1 ,1,0)  received
     FROM
-	    college_present_rule
-	LEFT JOIN ( SELECT context FROM college_points_detail WHERE openid = #{openid,jdbcType=VARCHAR}
-	and event_code = 4) AS tt
-	ON college_present_rule.id = tt.context
+	    college_present_rule  as cpr
 	order by seq asc
     </select>
 

+ 10 - 5
src/main/resources/mybatis/mapper/college/CollegeTestMapper.xml

@@ -29,11 +29,16 @@
 
 
     <select id="selectByCoreId" resultType="com.ygj.yuemum.domain.college.CollegeTest" parameterType="java.lang.Integer" >
-        select
-        *
-        from college_test
-        where core_id = #{core_id,jdbcType=INTEGER}
-        order by seq asc
+        SELECT
+            ct.*,
+            (select seq from college_test_result where isright = 1 and testid = ct.id)  as rightSeq
+        FROM
+            college_test  as ct
+        WHERE
+            core_id = #{core_id,jdbcType=INTEGER}
+
+        ORDER BY
+            ct.seq ASC
     </select>
 
     <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >