Просмотр исходного кода

1.base_transaction_record增加application_id字段。

tomatozq 5 лет назад
Родитель
Сommit
11d4aa76e3

+ 10 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/entity/TransactionRecord.java

@@ -18,6 +18,8 @@ public class TransactionRecord {
 	private String id;
     @ApiModelProperty(value = "企业ID")
 	private String companyId;
+	@ApiModelProperty(value = "投保单ID")
+	private String applicationId;
     @ApiModelProperty(value = "交易号")
 	private String transactionNumber;
     @ApiModelProperty(value = "交易金额")
@@ -216,4 +218,12 @@ public class TransactionRecord {
 	public void setDelFlag(Boolean delFlag){
 		this.delFlag = delFlag;
 	}
+
+	public String getApplicationId() {
+		return applicationId;
+	}
+
+	public void setApplicationId(String applicationId) {
+		this.applicationId = applicationId;
+	}
 }

+ 113 - 107
picc-common/src/main/resources/mapper/base/TransactionRecord.xml

@@ -1,120 +1,126 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- namespace必须指向DAO接口 -->
 <mapper namespace="com.jpsoft.picc.modules.base.dao.TransactionRecordDAO">
-	<resultMap id="TransactionRecordMap" type="com.jpsoft.picc.modules.base.entity.TransactionRecord">
-		<id property="id" column="id_" />
-			<result property="companyId" column="company_id" />
-			<result property="transactionNumber" column="transaction_number" />
-			<result property="amount" column="amount_" />
-			<result property="orderNo" column="order_no" />
-			<result property="paymentStatus" column="payment_status" />
-			<result property="buyType" column="buy_type" />
-			<result property="paymentTime" column="payment_time" />
-			<result property="createBy" column="create_by" />
-			<result property="createTime" column="create_time" />
-			<result property="updateBy" column="update_by" />
-			<result property="updateTime" column="update_time" />
-			<result property="delFlag" column="del_flag" />
-			</resultMap>
-	<insert id="insert" parameterType="com.jpsoft.picc.modules.base.entity.TransactionRecord">
-	<!--
-	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
-		select sys_guid() from dual
-	</selectKey>
-	-->
-	<![CDATA[
+    <resultMap id="TransactionRecordMap" type="com.jpsoft.picc.modules.base.entity.TransactionRecord">
+        <id property="id" column="id_"/>
+        <result property="companyId" column="company_id"/>
+        <result property="applicationId" column="application_id"/>
+        <result property="transactionNumber" column="transaction_number"/>
+        <result property="amount" column="amount_"/>
+        <result property="orderNo" column="order_no"/>
+        <result property="paymentStatus" column="payment_status"/>
+        <result property="buyType" column="buy_type"/>
+        <result property="paymentTime" column="payment_time"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="delFlag" column="del_flag"/>
+    </resultMap>
+    <insert id="insert" parameterType="com.jpsoft.picc.modules.base.entity.TransactionRecord">
+        <!--
+        <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+            select sys_guid() from dual
+        </selectKey>
+        -->
+        <![CDATA[
 		insert into base_transaction_record
-	    (id_,company_id,transaction_number,amount_,order_no,payment_status,buy_type,payment_time,create_by,create_time,update_by,update_time,del_flag)
+	    (id_,company_id,application_id,
+	    transaction_number,amount_,order_no,payment_status,
+	    buy_type,payment_time,create_by,create_time,update_by,update_time,del_flag)
 		values
 		(
-#{id,jdbcType=VARCHAR}
-,#{companyId,jdbcType=VARCHAR}
-,#{transactionNumber,jdbcType=VARCHAR}
-,#{amount,jdbcType= NUMERIC }
-,#{orderNo,jdbcType=VARCHAR}
-,#{paymentStatus,jdbcType=VARCHAR}
-,#{buyType,jdbcType=VARCHAR}
-,#{paymentTime,jdbcType= TIMESTAMP }
-,#{createBy,jdbcType=VARCHAR}
-,#{createTime,jdbcType= TIMESTAMP }
-,#{updateBy,jdbcType=VARCHAR}
-,#{updateTime,jdbcType= TIMESTAMP }
-,#{delFlag,jdbcType= NUMERIC }
+			#{id,jdbcType=VARCHAR}
+			,#{companyId,jdbcType=VARCHAR}
+			,#{applicationId,jdbcType=VARCHAR}
+			,#{transactionNumber,jdbcType=VARCHAR}
+			,#{amount,jdbcType= NUMERIC }
+			,#{orderNo,jdbcType=VARCHAR}
+			,#{paymentStatus,jdbcType=VARCHAR}
+			,#{buyType,jdbcType=VARCHAR}
+			,#{paymentTime,jdbcType= TIMESTAMP }
+			,#{createBy,jdbcType=VARCHAR}
+			,#{createTime,jdbcType= TIMESTAMP }
+			,#{updateBy,jdbcType=VARCHAR}
+			,#{updateTime,jdbcType= TIMESTAMP }
+			,#{delFlag,jdbcType= NUMERIC }
 		)
 	]]>
-	</insert>
-	<delete id="delete" parameterType="string">
-		delete from base_transaction_record where id_=#{id,jdbcType=VARCHAR}
-	</delete>
-	<update id="update" parameterType="com.jpsoft.picc.modules.base.entity.TransactionRecord">
-		update base_transaction_record
-		<set>
-				<if test="companyId!=null">
-		company_id=#{companyId,jdbcType=VARCHAR},
-		</if>
-				<if test="transactionNumber!=null">
-		transaction_number=#{transactionNumber,jdbcType=VARCHAR},
-		</if>
-				<if test="amount!=null">
-		amount_=#{amount,jdbcType= NUMERIC },
-		</if>
-				<if test="orderNo!=null">
-		order_no=#{orderNo,jdbcType=VARCHAR},
-		</if>
-				<if test="paymentStatus!=null">
-		payment_status=#{paymentStatus,jdbcType=VARCHAR},
-		</if>
-				<if test="buyType!=null">
-		buy_type=#{buyType,jdbcType=VARCHAR},
-		</if>
-				<if test="paymentTime!=null">
-		payment_time=#{paymentTime,jdbcType= TIMESTAMP },
-		</if>
-				<if test="createBy!=null">
-		create_by=#{createBy,jdbcType=VARCHAR},
-		</if>
-				<if test="createTime!=null">
-		create_time=#{createTime,jdbcType= TIMESTAMP },
-		</if>
-				<if test="updateBy!=null">
-		update_by=#{updateBy,jdbcType=VARCHAR},
-		</if>
-				<if test="updateTime!=null">
-		update_time=#{updateTime,jdbcType= TIMESTAMP },
-		</if>
-				<if test="delFlag!=null">
-		del_flag=#{delFlag,jdbcType= NUMERIC },
-		</if>
-		</set>
-	where id_=#{id}
-	</update>
-	<select id="get" parameterType="string" resultMap="TransactionRecordMap">
-		select
-id_,company_id,transaction_number,amount_,order_no,payment_status,buy_type,payment_time,create_by,create_time,update_by,update_time,del_flag		from base_transaction_record where id_=#{0}
-	</select>
-	<select id="exist" parameterType="string" resultType="int">
-		select count(*) from base_transaction_record where id_=#{0}
-	</select>
-	<select id="list" resultMap="TransactionRecordMap">
-		select * from base_transaction_record
-	</select>
-	<select id="search" parameterType="hashmap" resultMap="TransactionRecordMap">
-		<![CDATA[
+    </insert>
+    <delete id="delete" parameterType="string">
+        delete from base_transaction_record where id_=#{id,jdbcType=VARCHAR}
+    </delete>
+    <update id="update" parameterType="com.jpsoft.picc.modules.base.entity.TransactionRecord">
+        update base_transaction_record
+        <set>
+            <if test="companyId!=null">
+                company_id=#{companyId,jdbcType=VARCHAR},
+            </if>
+            <if test="applicationId!=null">
+                application_id=#{applicationId,jdbcType=VARCHAR},
+            </if>
+            <if test="transactionNumber!=null">
+                transaction_number=#{transactionNumber,jdbcType=VARCHAR},
+            </if>
+            <if test="amount!=null">
+                amount_=#{amount,jdbcType= NUMERIC },
+            </if>
+            <if test="orderNo!=null">
+                order_no=#{orderNo,jdbcType=VARCHAR},
+            </if>
+            <if test="paymentStatus!=null">
+                payment_status=#{paymentStatus,jdbcType=VARCHAR},
+            </if>
+            <if test="buyType!=null">
+                buy_type=#{buyType,jdbcType=VARCHAR},
+            </if>
+            <if test="paymentTime!=null">
+                payment_time=#{paymentTime,jdbcType= TIMESTAMP },
+            </if>
+            <if test="createBy!=null">
+                create_by=#{createBy,jdbcType=VARCHAR},
+            </if>
+            <if test="createTime!=null">
+                create_time=#{createTime,jdbcType= TIMESTAMP },
+            </if>
+            <if test="updateBy!=null">
+                update_by=#{updateBy,jdbcType=VARCHAR},
+            </if>
+            <if test="updateTime!=null">
+                update_time=#{updateTime,jdbcType= TIMESTAMP },
+            </if>
+            <if test="delFlag!=null">
+                del_flag=#{delFlag,jdbcType= NUMERIC },
+            </if>
+        </set>
+        where id_=#{id}
+    </update>
+    <select id="get" parameterType="string" resultMap="TransactionRecordMap">
+        select * from base_transaction_record where id_=#{0}
+    </select>
+    <select id="exist" parameterType="string" resultType="int">
+        select count(*) from base_transaction_record where id_=#{0}
+    </select>
+    <select id="list" resultMap="TransactionRecordMap">
+        select * from base_transaction_record
+    </select>
+    <select id="search" parameterType="hashmap" resultMap="TransactionRecordMap">
+        <![CDATA[
 			select * from base_transaction_record
 		]]>
-		<where>
-			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
-			</if>
-		</where>
-		<foreach item="sort" collection="sortList"  open="order by" separator=",">
-	        ${sort.name} ${sort.order}
-	 	</foreach>
-	</select>
+        <where>
+            <if test="searchParams.id != null">
+                and ID_ like #{searchParams.id}
+            </if>
+        </where>
+        <foreach item="sort" collection="sortList" open="order by" separator=",">
+            ${sort.name} ${sort.order}
+        </foreach>
+    </select>
 
-	<select id="getByOrderNo" resultMap="TransactionRecordMap">
-		select * from base_transaction_record where order_no = #{0}
-	</select>
+    <select id="getByOrderNo" resultMap="TransactionRecordMap">
+        select * from base_transaction_record where order_no = #{0}
+    </select>
 </mapper>

+ 6 - 1
picc-common/src/main/resources/mapper/business/InsuranceApplication.xml

@@ -158,7 +158,12 @@
         where id_=#{id}
     </update>
 	<select id="get" parameterType="string" resultMap="InsuranceApplicationMap">
-		select * from business_insurance_application where id_=#{0}
+        select * from (
+        select t1.*,t2.name_ as definition_name
+        from business_insurance_application t1
+        left join base_insurance_definition t2 on t1.definition_id = t2.id_
+        ) as t
+        where id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
 		select count(*) from business_insurance_application where id_=#{0} and del_flag = false

+ 1 - 1
picc-common/src/main/resources/mapper/business/InsurancePolicy.xml

@@ -183,7 +183,7 @@
 			) as t
 		]]>
         <where>
-            del_flag=0
+            del_flag=0 and a.no_>1
             <if test="searchParams.companyId != null">
                 and id_ in(
                     select b.policy_id from business_insurance_application a,business_application_policy b

+ 14 - 1
picc-enterprise-server/pom.xml

@@ -155,11 +155,24 @@
                     <artifactId>spring-boot-starter-tomcat</artifactId>
                 </dependency>
             </dependencies>
+            <properties>
+                <active.profile>dev</active.profile>
+            </properties>
             <activation>
                 <activeByDefault>true</activeByDefault>
             </activation>
+        </profile>
+        <profile>
+            <id>remote</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-tomcat</artifactId>
+                    <scope>provided</scope>
+                </dependency>
+            </dependencies>
             <properties>
-                <active.profile>dev</active.profile>
+                <active.profile>remote</active.profile>
             </properties>
         </profile>
         <profile>

+ 16 - 0
picc-enterprise-server/src/main/java/com/jpsoft/picc/config/JpCloudConfig.java

@@ -0,0 +1,16 @@
+package com.jpsoft.picc.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "jpcloud")
+@Data
+public class JpCloudConfig {
+    private String notifyBackUrl;
+    private String synchroBackUrl;
+    private String jpcloudUrl;
+    private String sellerSerialNumber;
+    private String platformCode;
+}

+ 128 - 15
picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/auth/controller/InsuranceApplicationController.java

@@ -1,51 +1,48 @@
 package com.jpsoft.picc.modules.auth.controller;
 
-import cn.hutool.core.date.DateUnit;
 import com.github.pagehelper.Page;
 import com.jpsoft.picc.modules.auth.dto.AcceptInsuranceDTO;
 import com.jpsoft.picc.modules.auth.dto.InsuranceApplicationDTO;
 import com.jpsoft.picc.modules.auth.dto.InsuranceJobsDTO;
 import com.jpsoft.picc.modules.base.entity.*;
 import com.jpsoft.picc.modules.base.service.*;
-import com.jpsoft.picc.modules.business.dao.InsurancePolicyDAO;
 import com.jpsoft.picc.modules.business.entity.ApplicationPolicy;
 import com.jpsoft.picc.modules.business.entity.InsuranceApplication;
 import com.jpsoft.picc.modules.business.entity.InsurancePolicy;
-import com.jpsoft.picc.modules.business.entity.InsurancePolicyMember;
 import com.jpsoft.picc.modules.business.service.ApplicationPolicyService;
 import com.jpsoft.picc.modules.business.service.InsuranceApplicationService;
 import com.jpsoft.picc.modules.business.service.InsurancePolicyMemberService;
 import com.jpsoft.picc.modules.business.service.InsurancePolicyService;
+import com.jpsoft.picc.config.JpCloudConfig;
 import com.jpsoft.picc.modules.common.constant.PolicyStatus;
 import com.jpsoft.picc.modules.common.dto.MessageResult;
 import com.jpsoft.picc.modules.common.dto.Sort;
 import com.jpsoft.picc.modules.common.utils.PojoUtils;
+import com.jpsoft.picc.modules.common.utils.SignUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.jasig.cas.client.authentication.AttributePrincipal;
 import org.joda.time.DateTime;
 import org.joda.time.Interval;
-import org.joda.time.Period;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
+import java.net.URLEncoder;
+import java.security.Policy;
 import java.util.*;
 
+@Slf4j
 @Api(description="投保信息")
 @RestController
 @RequestMapping("/auth/insuranceApplication")
 public class InsuranceApplicationController {
-    private Logger logger = LoggerFactory.getLogger(getClass());
-
     @Autowired
     private InsuranceApplicationService insuranceApplicationService;
 
@@ -73,6 +70,12 @@ public class InsuranceApplicationController {
     @Autowired
     private ApplicationPolicyService applicationPolicyService;
 
+    @Autowired
+    private JpCloudConfig jpCloudConfig;
+
+    @Autowired
+    private TransactionRecordService transactionRecordService;
+
     @ApiOperation(value="投保单列表")
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     @ApiImplicitParams({
@@ -125,7 +128,7 @@ public class InsuranceApplicationController {
             msgResult.setResult(true);
         }
         catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(),ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());
@@ -214,7 +217,7 @@ public class InsuranceApplicationController {
             msgResult.setResult(true);
         }
         catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(),ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());
@@ -309,7 +312,7 @@ public class InsuranceApplicationController {
             msgResult.setResult(true);
         }
         catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(),ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());
@@ -387,7 +390,7 @@ public class InsuranceApplicationController {
             msgResult.setResult(true);
         }
         catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(),ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());
@@ -451,7 +454,7 @@ public class InsuranceApplicationController {
             }
         }
         catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(),ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());
@@ -489,7 +492,117 @@ public class InsuranceApplicationController {
             }
         }
         catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @PostMapping(value="changeStatus")
+    @ApiOperation(value = "修改投保单状态(测试用)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "applicationId",value = "投保单编号", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "status",value = "状态:草稿10/已退回15/待初审20/待复审30/待缴费40/待制单50/待出单60/已出单70/已过期100", required = true, paramType = "form"),
+    })
+    public MessageResult<String> changeStatus(String applicationId,String status){
+        MessageResult<String> messageResult = new MessageResult<>();
+
+        try {
+            //todo
+            InsuranceApplication insuranceApplication = insuranceApplicationService.get(applicationId);
+            insuranceApplication.setStatus(status);
+            insuranceApplication.setUpdateTime(new Date());
+
+            insuranceApplicationService.update(insuranceApplication);
+
+            messageResult.setResult(true);
+        }
+        catch (Exception ex){
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+
+    @ResponseBody
+    @ApiOperation(value="缴费接口")
+    @ApiImplicitParam(name = "applicationId",value = "投保单编号",paramType ="form",required = true)
+    @PostMapping(value="/paySubmit")
+    public MessageResult paySubmit(HttpServletRequest request,String applicationId){
+        MessageResult msgResult = new MessageResult<>();
+
+        try {
+            InsuranceApplication insuranceApplication = insuranceApplicationService.get(applicationId);
+
+            if(insuranceApplication==null){
+                throw new Exception("投保单不存在!");
+            }
+
+            if(!String.valueOf(PolicyStatus.PendingPay.getValue()).equals(insuranceApplication.getStatus())){
+                throw new Exception("投保单当前状态不是待缴费状态!");
+            }
+
+            AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
+            Company company = companyService.findByCreateBy(principal.getName());
+
+            String serialNumber = (String)principal.getAttributes().get("serialNumber");
+
+            TransactionRecord transactionRecord = new TransactionRecord();
+            transactionRecord.setId(UUID.randomUUID().toString());
+            transactionRecord.setApplicationId(applicationId);
+            transactionRecord.setCompanyId(company.getId());
+            transactionRecord.setAmount(insuranceApplication.getInsuranceFee());
+            transactionRecord.setPaymentStatus("0");
+            transactionRecord.setOrderNo(DateTime.now().toString("yyyyMMddHHmmssSSS"));
+            transactionRecord.setCreateBy(principal.getName());
+            transactionRecord.setCreateTime(new Date());
+
+            int affectCount = transactionRecordService.insert(transactionRecord);
+
+            if(affectCount==0){
+                throw new Exception("创建交易单失败!");
+            }
+
+            HashMap<String, Object> paramMap = new HashMap<String, Object>();
+            paramMap.put("orderNo", transactionRecord.getOrderNo());
+            paramMap.put("orderName", insuranceApplication.getDefinitionName() + "网上缴费");
+            paramMap.put("freezeTime", transactionRecord.getCreateTime().getTime() / 1000);
+            paramMap.put("unfreezeTime", transactionRecord.getCreateTime().getTime() / 1000);
+            paramMap.put("orderAmount", transactionRecord.getAmount());
+            paramMap.put("code", jpCloudConfig.getPlatformCode()); //平台号
+            paramMap.put("buyerSerialNumber", serialNumber);//取登录用户的ID
+            paramMap.put("sellerSerialNumber", jpCloudConfig.getSellerSerialNumber());
+            paramMap.put("notifyBackUrl", jpCloudConfig.getNotifyBackUrl());
+            paramMap.put("synchroBackUrl", jpCloudConfig.getSynchroBackUrl());
+            String sign = SignUtil.createSign(paramMap, "1234567890");
+
+            paramMap.put("orderName", URLEncoder.encode(insuranceApplication.getDefinitionName() + "网上缴费","UTF-8"));
+            paramMap.put("notifyBackUrl", URLEncoder.encode(jpCloudConfig.getNotifyBackUrl(),"UTF-8"));
+            paramMap.put("synchroBackUrl", URLEncoder.encode(jpCloudConfig.getSynchroBackUrl(),"UTF-8"));
+
+            paramMap.put("sign", sign);
+
+            String param = "";
+
+            for (Map.Entry<String, Object> map : paramMap.entrySet()) {
+                param += map.getKey() + "=" + map.getValue() + "&";
+            }
+
+            if (StringUtils.isNotBlank(param)) {
+                param = param.substring(0, param.length() - 1);
+            }
+            String returnUrl = jpCloudConfig.getJpcloudUrl() + "?" + param;
+
+            msgResult.setData(returnUrl);
+            msgResult.setResult(true);
+        }
+        catch(Exception ex){
+            log.error(ex.getMessage(),ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());

+ 33 - 0
picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/auth/controller/InsurancePolicyController.java

@@ -12,6 +12,7 @@ import com.jpsoft.picc.modules.common.constant.PolicyStatus;
 import com.jpsoft.picc.modules.common.dto.MessageResult;
 import com.jpsoft.picc.modules.common.dto.Sort;
 import com.jpsoft.picc.modules.common.utils.PojoUtils;
+import com.jpsoft.picc.modules.common.utils.SignUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -66,6 +67,9 @@ public class InsurancePolicyController {
     @Autowired
     private InsuranceDefinitionService insuranceDefinitionService;
 
+    @Autowired
+    private TransactionRecordService transactionRecordService;
+
     @Autowired
     private JobsService jobsService;
 
@@ -523,4 +527,33 @@ public class InsurancePolicyController {
             insurancePolicyMemberService.insert(destMember);
         }
     }
+
+
+
+    @PostMapping(value="changeStatus")
+    @ApiOperation(value = "修改投保单状态(测试用)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "policyId",value = "投保单编号", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "status",value = "状态:草稿10/已退回15/待初审20/待复审30/待缴费40/待制单50/待出单60/已出单70/已过期100", required = true, paramType = "form"),
+    })
+    public MessageResult<String> changeStatus(String policyId,String status){
+        MessageResult<String> messageResult = new MessageResult<>();
+
+        try {
+            //todo
+            InsurancePolicy insurancePolicy = insurancePolicyService.get(policyId);
+            insurancePolicy.setStatus(status);
+            insurancePolicy.setUpdateTime(new Date());
+
+            insurancePolicyService.update(insurancePolicy);
+
+            messageResult.setResult(true);
+        }
+        catch (Exception ex){
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
 }

+ 34 - 74
picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/pay/controller/Pay.java → picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/pub/controller/PayController.java

@@ -1,23 +1,25 @@
-package com.jpsoft.picc.modules.pay.controller;
+package com.jpsoft.picc.modules.pub.controller;
 
 import cn.hutool.json.JSONObject;
+import com.jpsoft.picc.config.JpCloudConfig;
 import com.jpsoft.picc.modules.base.entity.TransactionRecord;
 import com.jpsoft.picc.modules.base.service.CompanyService;
 import com.jpsoft.picc.modules.base.service.TransactionRecordService;
+import com.jpsoft.picc.modules.business.entity.InsuranceApplication;
+import com.jpsoft.picc.modules.business.service.InsuranceApplicationService;
+import com.jpsoft.picc.modules.common.constant.PolicyStatus;
 import com.jpsoft.picc.modules.common.dto.MessageResult;
 import com.jpsoft.picc.modules.common.utils.SignUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.Date;
@@ -31,83 +33,30 @@ import java.util.Map;
 
 @Controller
 @RequestMapping("/pay")
-@Api("支付")
-public class Pay {
-
-    @Value("${notifyBackUrl}")
-    private String notifyBackUrl;
-
-    @Value("${synchroBackUrl}")
-    private String synchroBackUrl;
-
-    @Value("${jpcloudUrl}")
-    private String jpcloudUrl;
-
-    @Value("${sellerSerialNumber}")
-    private String sellerSerialNumber;
+@Api(description="支付接口")
+@Slf4j
+public class PayController {
+    @Autowired
+    private JpCloudConfig jpCloudConfig;
 
     @Autowired
     private TransactionRecordService transactionRecordService;
 
     @Autowired
-    private CompanyService companyService;
-
-
-    @ResponseBody
-    @ApiOperation(value="支付")
-    @ApiImplicitParam(name = "id",value = "流水号id", required = true)
-    @RequestMapping(value="/paySubmit/{id}")
-    public MessageResult paySubmit(HttpServletRequest request, @PathVariable("id") String id){
-
-        //TODO 买家串号获取修改
-        TransactionRecord transactionRecord = transactionRecordService.get(id);
-
-     //   AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
-      //  Company company = companyService.findBy(principal.getName());
-
-
-
-        HashMap<String,Object> paramMap = new HashMap<String,Object>();
-        paramMap.put("orderNo", transactionRecord.getOrderNo());
-        paramMap.put("orderName", "PICC");
-        paramMap.put("freezeTime", transactionRecord.getCreateTime().getTime()/1000);
-        paramMap.put("unfreezeTime", transactionRecord.getCreateTime().getTime()/1000);
-        paramMap.put("orderAmount", transactionRecord.getAmount());
-        paramMap.put("code", "0008");
-        paramMap.put("buyerSerialNumber", "000101000178");//取登录用户的ID
-        paramMap.put("sellerSerialNumber", sellerSerialNumber);
-        paramMap.put("notifyBackUrl", notifyBackUrl);
-        paramMap.put("synchroBackUrl", synchroBackUrl);
-        String sign = SignUtil.createSign(paramMap, "1234567890");
-        paramMap.put("sign", sign);
-
-        String param = "";
+    private InsuranceApplicationService insuranceApplicationService;
 
-        for (Map.Entry<String, Object> map : paramMap.entrySet()) {
-            param += map.getKey() + "=" + map.getValue() + "&";
-        }
-
-        if(StringUtils.isNotBlank(param)){
-            param = param.substring(0,param.length()-1);
-        }
-        String returnUrl=jpcloudUrl+"?"+param;
-        MessageResult msgResult = new MessageResult<>();
-        msgResult.setData(returnUrl);
-        msgResult.setResult(true);
-
-
-        return msgResult;
-    }
+    @Autowired
+    private CompanyService companyService;
 
-    @RequestMapping(value = "/orderNotifyBack")
+    @PostMapping(value = "/orderNotifyBack")
     @ResponseBody
-    public  MessageResult<?> orderNotifyBack(HttpServletRequest req,String payTime,String payType,String orderNo,String sign) {
+    public Map orderNotifyBack(HttpServletRequest req,String payTime,String payType,String orderNo,String sign) {
         HashMap<String, Object> retMap = new HashMap<String, Object>();
 
         String status = "success";
         String message = "订单支付成功";
         JSONObject body = new JSONObject();
-        System.out.println("payTime>>>" + payTime + "paymentType>>>" + payType + ">>>>orderNo>>" + orderNo + "sign>>>" + sign);
+        log.warn("payTime>>>" + payTime + "paymentType>>>" + payType + ">>>>orderNo>>" + orderNo + "sign>>>" + sign);
         if(StringUtils.isNotBlank(payType) && StringUtils.isNotBlank(orderNo)){
 
             HashMap<String,Object> signMap = new HashMap<String,Object>();
@@ -124,12 +73,25 @@ public class Pay {
 
             if(result){
                 TransactionRecord transactionRecord = transactionRecordService.getByOrderNo(orderNo);
-                if(transactionRecord != null && transactionRecord.getPaymentStatus() != "20"){
+
+                InsuranceApplication insuranceApplication = insuranceApplicationService.get(transactionRecord.getApplicationId());
+
+                if(transactionRecord != null && !"20".equals(transactionRecord.getPaymentStatus())){
                     transactionRecord.setPaymentStatus("20");
                     transactionRecord.setPaymentTime(new Date());
                     transactionRecord.setBuyType(payType);
+                    transactionRecord.setUpdateTime(new Date());
+
                     transactionRecordService.update(transactionRecord);
 
+                    //将投保单状态改为待制单
+                    if(insuranceApplication!=null) {
+                        insuranceApplication.setStatus(PolicyStatus.PendingMakePolicy.getValue() + "");
+                        insuranceApplication.setUpdateTime(new Date());
+
+                        insuranceApplicationService.update(insuranceApplication);
+                    }
+
                     body.put("orderNo", orderNo);
                     body.put("backStatus", "回调成功");
                     body.put("backTime", new Date().getTime()/1000);
@@ -149,14 +111,12 @@ public class Pay {
             message = "订单号不存在";
             status = "fail";
         }
+
         retMap.put("status", status);
         retMap.put("message", message);
         retMap.put("body", body);
-        MessageResult msgResult = new MessageResult<>();
-        msgResult.setData(retMap);
-        msgResult.setResult(true);
 
-        return msgResult;
+        return retMap;
     }
 
     @GetMapping(value="/paySuccess")

+ 7 - 0
picc-enterprise-server/src/main/resources/application-dev.yml

@@ -15,6 +15,13 @@ cas:
   # 如果不设则无法获取用户扩展信息
   validation-type: cas
 
+jpcloud:
+  notifyBackUrl: http://gyxm.jing-zhou.gov.cn/picc-enterprise-server/pay/orderNotifyBack
+  synchroBackUrl: http://gyxm.jing-zhou.gov.cn/picc-enterprise-server/pay/paySuccess
+  jpcloudUrl: http://gyxm.jing-zhou.gov.cn/jp-cloud-api/payment/tradingOrderPayPc
+  sellerSerialNumber: '000001000020'
+  platformCode: '0008'
+
 logger:
   level: WARN
   dir: D:\\Logs\\picc\\picc-enterprise-server\\

+ 7 - 0
picc-enterprise-server/src/main/resources/application-remote.yml

@@ -21,6 +21,13 @@ cas:
   # 如果不设则无法获取用户扩展信息
   validation-type: cas
 
+jpcloud:
+  notifyBackUrl: http://gyxm.jing-zhou.gov.cn/picc-enterprise-server/pay/orderNotifyBack
+  synchroBackUrl: http://gyxm.jing-zhou.gov.cn/picc-enterprise-server/pay/paySuccess
+  jpcloudUrl: http://gyxm.jing-zhou.gov.cn/jp-cloud-api/payment/tradingOrderPayPc
+  sellerSerialNumber: '000001000020'
+  platformCode: '0008'
+
 springfox:
   documentation:
     swagger:

+ 5 - 4
picc-enterprise-server/src/main/resources/application.yml

@@ -85,7 +85,8 @@ oss:
   urlPrefix: http://vod.wzgh.org
   objectPre: picc
 
-notifyBackUrl: http://18891j25i6.iok.la:40309/picc-enterprise-server/pay/orderNotifyBack
-synchroBackUrl: http://18891j25i6.iok.la:40309/picc-enterprise-server/pay/paySuccess
-jpcloudUrl: http://gyxm.jing-zhou.gov.cn/jp-cloud-api/payment/tradingOrderPayPc
-sellerSerialNumber: '000001000020'
+jpcloud:
+  notifyBackUrl: http://18891j25i6.iok.la:40309/picc-enterprise-server/pay/orderNotifyBack
+  synchroBackUrl: http://18891j25i6.iok.la:40309/picc-enterprise-server/pay/paySuccess
+  jpcloudUrl: http://gyxm.jing-zhou.gov.cn/jp-cloud-api/payment/tradingOrderPayPc
+  sellerSerialNumber: '000001000020'