Procházet zdrojové kódy

用户端抵用券开发

anderx před 7 roky
rodič
revize
5f252015a8

+ 4 - 0
src/main/java/com/goafanti/common/dao/UserMapper.java

@@ -117,4 +117,8 @@ public interface UserMapper {
 	int getCountByMobile(@Param("id")String id,@Param("mobile")String mobile);
 
 	List<String> getUserListMobile();
+
+	String getInvitationCode(String uid);
+
+	User getToInviteCode(String toInviteCode);
 }

+ 5 - 3
src/main/java/com/goafanti/common/enums/VoucherSourceType.java

@@ -7,9 +7,11 @@ import org.apache.commons.lang3.StringUtils;
 
 public enum VoucherSourceType {
 	
-	ZC(0, "注册"),
-	FQ(1, "返券"),
-	HD(2, "活动"),
+	YQGR(0, "邀请个人"),
+	YQFWS(1, "邀请服务商"),
+	BYQGR(2, "被邀请个人"),
+	BYQFWS(3, "被邀请服务商"),
+	HD(3, "活动"),
 	OTHER(3, "其他");
 
 	private VoucherSourceType(Integer code, String desc) {

+ 16 - 1
src/main/java/com/goafanti/common/mapper/JtVoucherDetailMapper.xml

@@ -307,6 +307,9 @@
 		left join jt_voucher_detail b on a.id=b.voucher_id
 		left join user c on b.use_uid=c.id
 		where 1=1
+	<if test="uid != null">
+		and  b.use_uid  = #{uid,jdbcType=VARCHAR}
+	</if>	
 	<if test="name != null">
 		and  a.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
 	</if>  
@@ -319,7 +322,16 @@
 	<if test="source != null">
 		and  a.source = #{source,jdbcType=INTEGER}
 	</if>
-	order by name
+	
+	<if test="sort == 0">
+		order by a.money 
+	</if>
+	<if test="sort == 1">
+		order by b.receive_time
+	</if>
+	<if test="sortType != null">
+	 desc
+	 </if>
   	<if test="page_sql!=null">
 		${page_sql}
 	</if>
@@ -330,6 +342,9 @@
 	left join jt_voucher_detail b on a.id=b.voucher_id
 	left join user c on b.use_uid=c.id
 	where 1=1
+	<if test="uid != null">
+		and  b.use_uid  = #{uid,jdbcType=VARCHAR}
+	</if>	
 	<if test="name != null">
 		and  a.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
 	</if>  

+ 7 - 0
src/main/java/com/goafanti/common/mapper/JtVoucherMapper.xml

@@ -355,6 +355,10 @@
   	limit_use as limitUse, limit_project_id as limitProjectId
    from jt_voucher
    where 1=1
+   <if test="uid != null">
+   		and limitUse= 1
+		and  granting_uid = #{uid,jdbcType=VARCHAR} 
+		</if>
    <if test="name != null">
 		and  name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
 	</if>  
@@ -378,6 +382,9 @@
   	count(*)
    from jt_voucher
    where 1=1
+   <if test="uid != null">
+		and  granting_uid = #{uid,jdbcType=VARCHAR} 
+		</if>
    <if test="name != null">
 		and  name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
 	</if>  

+ 40 - 5
src/main/java/com/goafanti/common/mapper/UserMapper.xml

@@ -36,6 +36,8 @@
     <result column="username" jdbcType="VARCHAR" property="username" />
     <result column="authentication" jdbcType="INTEGER" property="authentication" />
     <result column="introduction" jdbcType="VARCHAR" property="introduction" />
+    <result column="be_invite_code" jdbcType="VARCHAR" property="beInviteCode" />
+    <result column="to_invite_code" jdbcType="VARCHAR" property="toInviteCode" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <!--
@@ -114,7 +116,7 @@
     id, mobile, password, nickname, email, create_time, number, lvl, type, mid, status, 
     source, update_time, company_logo_url, head_portrait_url, society_tag, introduction, 
     value_added_tag, organization_id, identify_name, background_url, audit_opinion, audit_status, 
-    share_type, aid, transfer_time, username, authentication
+    share_type, aid, transfer_time, username, authentication,be_invite_code,to_invite_code
   </sql>
   <select id="selectByExample" parameterType="com.goafanti.common.model.UserExample" resultMap="BaseResultMap">
     <!--
@@ -180,7 +182,8 @@
       introduction, value_added_tag, organization_id, 
       identify_name, background_url, audit_opinion, 
       audit_status, share_type, aid, 
-      transfer_time, username, authentication
+      transfer_time, username, authentication,be_invite_code,to_invite_code
+      
       )
     values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, 
       #{nickname,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
@@ -190,7 +193,9 @@
       #{introduction,jdbcType=VARCHAR}, #{valueAddedTag,jdbcType=VARCHAR}, #{organizationId,jdbcType=VARCHAR}, 
       #{identifyName,jdbcType=VARCHAR}, #{backgroundUrl,jdbcType=VARCHAR}, #{auditOpinion,jdbcType=VARCHAR}, 
       #{auditStatus,jdbcType=INTEGER}, #{shareType,jdbcType=INTEGER}, #{aid,jdbcType=VARCHAR}, 
-      #{transferTime,jdbcType=TIMESTAMP}, #{username,jdbcType=VARCHAR}, #{authentication,jdbcType=INTEGER}
+      #{transferTime,jdbcType=TIMESTAMP}, #{username,jdbcType=VARCHAR}, #{authentication,jdbcType=INTEGER},
+      #{beInviteCode,jdbcType=VARCHAR},#{toInviteCode,jdbcType=VARCHAR} 
+      
       )
   </insert>
   <insert id="insertSelective" parameterType="com.goafanti.common.model.User">
@@ -285,6 +290,12 @@
       <if test="authentication != null">
         authentication,
       </if>
+      <if test="beInviteCode != null">
+        be_invite_code,
+      </if>
+      <if test="toInviteCode != null">
+        to_invite_code,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -371,6 +382,12 @@
       <if test="authentication != null">
         #{authentication,jdbcType=INTEGER},
       </if>
+      <if test="beInviteCode != null">
+        #{beInviteCode,jdbcType=VARCHAR},
+      </if>
+      <if test="toInviteCode != null">
+      #{toInviteCode,jdbcType=VARCHAR},    
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.goafanti.common.model.UserExample" resultType="java.lang.Long">
@@ -515,7 +532,9 @@
       aid = #{record.aid,jdbcType=VARCHAR},
       transfer_time = #{record.transferTime,jdbcType=TIMESTAMP},
       username = #{record.username,jdbcType=VARCHAR},
-      authentication = #{record.authentication,jdbcType=INTEGER}
+      authentication = #{record.authentication,jdbcType=INTEGER},
+      be_invite_code = #{beInviteCode,jdbcType=VARCHAR},
+      to_invite_code = #{toInviteCode,jdbcType=VARCHAR}   
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -609,6 +628,12 @@
       <if test="authentication != null">
         authentication = #{authentication,jdbcType=INTEGER},
       </if>
+      <if test="beInviteCode != null">
+        be_invite_code = #{beInviteCode,jdbcType=VARCHAR},
+      </if>
+      <if test="toInviteCode != null">
+        to_invite_code = #{toInviteCode,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -645,7 +670,9 @@
       aid = #{aid,jdbcType=VARCHAR},
       transfer_time = #{transferTime,jdbcType=TIMESTAMP},
       username = #{username,jdbcType=VARCHAR},
-      authentication = #{authentication,jdbcType=INTEGER}
+      authentication = #{authentication,jdbcType=INTEGER},
+       be_invite_code = #{beInviteCode,jdbcType=VARCHAR},
+       to_invite_code = #{toInviteCode,jdbcType=VARCHAR}
     where id = #{id,jdbcType=VARCHAR}
   </update>
  
@@ -1256,5 +1283,13 @@
  		and source=0
  		and audit_status=2
 	</select>
+	<select id="getInvitationCode" resultType="java.lang.String">
+	select to_invite_code from `user` where id= #{uid,jdbcType=VARCHAR}
+	</select>
+	<select id="getToBackgroundUrl" resultMap="BaseResultMap">
+	select 
+	<include refid="Base_Column_List" />
+	from `user` from to_invite_code= #{toInviteCode,jdbcType=VARCHAR}
+	</select>
 
 </mapper>

+ 20 - 0
src/main/java/com/goafanti/common/model/User.java

@@ -144,6 +144,10 @@ public class  User  extends BaseModel implements AftUser {
 	 * @mbg.generated  Thu May 31 15:33:56 CST 2018
 	 */
 	private Integer authentication;
+	
+	private String toInviteCode;
+	
+	private String beInviteCode;
 
 	/**
 	 * This method was generated by MyBatis Generator. This method returns the value of the database column user.id
@@ -649,6 +653,22 @@ public class  User  extends BaseModel implements AftUser {
 		this.authentication = authentication;
 	}
 
+	public String getToInviteCode() {
+		return toInviteCode;
+	}
+
+	public void setToInviteCode(String toInviteCode) {
+		this.toInviteCode = toInviteCode;
+	}
+
+	public String getBeInviteCode() {
+		return beInviteCode;
+	}
+
+	public void setBeInviteCode(String beInviteCode) {
+		this.beInviteCode = beInviteCode;
+	}
+
 	/**
 	 * 
 	 */

+ 10 - 0
src/main/java/com/goafanti/user/bo/InputUser.java

@@ -23,6 +23,8 @@ public class InputUser {
 	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
 	private Integer	type;
 	
+	private String beInviteCode;
+	
 	public Integer getType() {
 		return type;
 	}
@@ -62,4 +64,12 @@ public class InputUser {
 	public void setUsername(String username) {
 		this.username = username;
 	}
+
+	public String getBeInviteCode() {
+		return beInviteCode;
+	}
+
+	public void setBeInviteCode(String beInviteCode) {
+		this.beInviteCode = beInviteCode;
+	}
 }

+ 17 - 1
src/main/java/com/goafanti/user/controller/UserApiController.java

@@ -66,7 +66,7 @@ import com.goafanti.user.service.UserIdentityService;
 import com.goafanti.user.service.UserService;
 
 @RestController
-@RequestMapping(value = "/api/user")
+@RequestMapping(value = "/open/api/user")
 public class UserApiController extends BaseApiController {
 	@Resource
 	private UserService						userService;
@@ -1003,6 +1003,22 @@ public class UserApiController extends BaseApiController {
         }
 		return res;
 	}
+	/**
+	 * 获取用户邀请码
+	 */
+	@RequestMapping(value = "/InvitationCode", method = RequestMethod.GET)
+	public Result InvitationCode(String uid) {
+		Result res = new Result();
+		if (uid==null) {
+			if(!(TokenManager.getToken() instanceof User)||TokenManager.getUserId()==null){
+			res.getError().add(buildError("未获取到用户信息", "未获取到用户信息"));
+			return res;
+			}
+			uid=TokenManager.getUserId();
+		}
+		res.data(userService.updateGetInvitationCode(uid));
+		return res;
+	}
 	
 
 

+ 21 - 13
src/main/java/com/goafanti/user/controller/UserRegisterController.java

@@ -18,9 +18,11 @@ import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.BaseController;
+import com.goafanti.common.dao.UserMapper;
 import com.goafanti.common.enums.UserAuthentication;
 import com.goafanti.common.enums.UserFields;
 import com.goafanti.common.enums.UserLevel;
+import com.goafanti.common.enums.VoucherSourceType;
 import com.goafanti.common.model.JtVoucherDetail;
 import com.goafanti.common.model.User;
 import com.goafanti.common.utils.PasswordUtil;
@@ -104,6 +106,7 @@ public class UserRegisterController extends BaseController {
 			us.setNickname(user.getUnitName());
 			us.setSource(AFTConstants.USER_SOURCE_REGISTER);
 			us.setType(user.getType());
+			us.setBeInviteCode(user.getBeInviteCode());
 			us.setStatus(AFTConstants.USER_STATUS_NORMAL);
 			us.setShareType(AFTConstants.USER_SHARE_PUBLIC);
 			us.setIdentifyName(StringUtils.isBlank(user.getUnitName())?"":user.getUnitName());
@@ -112,7 +115,7 @@ public class UserRegisterController extends BaseController {
 			us.setTransferTime(now.getTime());
 			userService.insertRegister(us,user.getUnitName(),user.getUsername());
 			//获得抵用券
-			getVoucher(us.getId());
+			userService.getVoucher(us);
 		}
 		return res;
 	}
@@ -166,6 +169,7 @@ public class UserRegisterController extends BaseController {
 			us.setPassword(passwordUtil.getEncryptPwd(us));
 			us.setNickname(user.getUnitName());
 			us.setType(user.getType());
+			us.setBeInviteCode(user.getBeInviteCode());
 			us.setSource(AFTConstants.USER_SOURCE_REGISTER);
 			us.setStatus(AFTConstants.USER_STATUS_NORMAL);
 			us.setShareType(AFTConstants.USER_SHARE_PUBLIC);
@@ -175,25 +179,29 @@ public class UserRegisterController extends BaseController {
 			us.setTransferTime(now.getTime());
 			userService.insertRegister(us,user.getUnitName(),user.getUsername());
 			//获得抵用券
-			getVoucher(us.getId());
+			userService.getVoucher(us);
 		}
 		return res;
 	}
 	
-	public void getVoucher(String uid){
-		List<String> ids=voucherService.getSourceVoucher(0);
-		for (String s : ids) {
-			JtVoucherDetail j=new JtVoucherDetail();
-			j.setId(jDBCIdGenerator.generateId().toString());
-			j.setReceiveTime(new Date());
-			j.setVoucherId(s);
-			j.setUseUid(uid);
-			j.setStatus(0);
-			voucherDetailService.saveVoucherDetail(j);
+	/*public void getVoucher(User u){
+		if (StringUtils.isNotBlank(u.getBackgroundUrl())) {
+			
+			List<String> ids=voucherService.getSourceVoucher(VoucherSourceType.BYQFWS.getCode());
+			for (String s : ids) {
+				JtVoucherDetail j=new JtVoucherDetail();
+				j.setId(jDBCIdGenerator.generateId().toString());
+				j.setReceiveTime(new Date());
+				j.setVoucherId(s);
+				j.setUseUid(u.getId());
+				j.setStatus(0);
+				voucherDetailService.saveVoucherDetail(j);
+			}
+			
 		}
 	}
 	
-	/*private void registerEasemobAfterRegister(String uuid,User u){
+	private void registerEasemobAfterRegister(String uuid,User u){
 			JSONObject resultObj = new JSONObject();
 			String easemobName =  String.valueOf(u.getNumber());
 			String easemobPass = new SimpleHash("md5", u.getId(), null, 1).toHex();

+ 4 - 0
src/main/java/com/goafanti/user/service/UserService.java

@@ -69,5 +69,9 @@ public interface UserService {
 	 * @return
 	 */
 	int getCountByMobile(String id, String mobile);
+
+	String updateGetInvitationCode(String uid);
+
+	void getVoucher(User us);
 	
 }

+ 42 - 1
src/main/java/com/goafanti/user/service/impl/UserIdentityServiceImpl.java

@@ -2,6 +2,7 @@ package com.goafanti.user.service.impl;
 
 import java.util.ArrayList;
 import java.util.Calendar;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -9,6 +10,8 @@ import java.util.UUID;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import javax.annotation.Resource;
+
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -39,14 +42,17 @@ import com.goafanti.common.enums.NoticeReadStatus;
 import com.goafanti.common.enums.NoticeStatus;
 import com.goafanti.common.enums.SocietyTagStatus;
 import com.goafanti.common.enums.UserLevel;
+import com.goafanti.common.enums.VoucherSourceType;
 import com.goafanti.common.enums.collectType;
 import com.goafanti.common.model.JtCollectSearch;
+import com.goafanti.common.model.JtVoucherDetail;
 import com.goafanti.common.model.Notice;
 import com.goafanti.common.model.User;
 import com.goafanti.common.model.UserIdentity;
 import com.goafanti.common.utils.LoggerUtils;
 import com.goafanti.common.utils.MobileMessageUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.JDBCIdGenerator;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.portal.bo.UserSubscriberListBo;
@@ -58,6 +64,8 @@ import com.goafanti.user.bo.MyInterestedBo;
 import com.goafanti.user.bo.UserIdentityBo;
 import com.goafanti.user.bo.UserIdentityDetailAdminBo;
 import com.goafanti.user.service.UserIdentityService;
+import com.goafanti.voucher.service.VoucherDetailService;
+import com.goafanti.voucher.service.VoucherService;
 
 @Service
 public class UserIdentityServiceImpl extends BaseMybatisDao<UserIdentityMapper> implements UserIdentityService {
@@ -77,6 +85,12 @@ public class UserIdentityServiceImpl extends BaseMybatisDao<UserIdentityMapper>
 	UserInterestMapper	userInterestMapper;
 	@Autowired
 	JtCollectSearchMapper	jtCollectSearchMapper;
+	@Autowired
+	private VoucherService		voucherService;
+	@Autowired
+	private VoucherDetailService	voucherDetailService;
+	@Resource
+	private JDBCIdGenerator	jDBCIdGenerator;
 	@Value(value="${collect_flag}")
 	private Boolean collectFlag ;
 	@Value(value = "${examineAdopt}")
@@ -621,7 +635,9 @@ public class UserIdentityServiceImpl extends BaseMybatisDao<UserIdentityMapper>
 					}
 					//通过后短信通知
 					examineSendMessage(u, str, examineAdopt);
-					
+					//抵用券发放
+					User user=userMapper.selectByPrimaryKey(u.getUid());
+					getVoucher(user);
 				}
 				r.setKeyword(SocietyTagStatus.getStatus(u.getKeyword()).getDesc());
 				r.setTitle(u.getUsername());
@@ -723,5 +739,30 @@ public class UserIdentityServiceImpl extends BaseMybatisDao<UserIdentityMapper>
 		return userIdentityMapper.getRandAdviserByType(exceptid, consultantType, size);
 	}
 	
+	public void getVoucher(User us) {
+		if (StringUtils.isNotBlank(us.getBeInviteCode())) {
+			List<String> ids=voucherService.getSourceVoucher(VoucherSourceType.BYQFWS.getCode());
+			for (String s : ids) {
+				JtVoucherDetail j=new JtVoucherDetail();
+				j.setId(jDBCIdGenerator.generateId().toString());
+				j.setReceiveTime(new Date());
+				j.setVoucherId(s);
+				j.setUseUid(us.getId());
+				j.setStatus(0);
+				voucherDetailService.saveVoucherDetail(j);
+			}
+			User toUser=userMapper.getToInviteCode(us.getBeInviteCode());
+			List<String> ids2=voucherService.getSourceVoucher(VoucherSourceType.YQFWS.getCode());
+			for (String string : ids2) {
+				JtVoucherDetail j=new JtVoucherDetail();
+				j.setId(jDBCIdGenerator.generateId().toString());
+				j.setReceiveTime(new Date());
+				j.setVoucherId(string);
+				j.setUseUid(toUser.getId());
+				j.setStatus(0);
+				voucherDetailService.saveVoucherDetail(j);
+			}
+		}
+	}
 
 }

+ 56 - 0
src/main/java/com/goafanti/user/service/impl/UserServiceImpl.java

@@ -1,9 +1,12 @@
 package com.goafanti.user.service.impl;
 
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.annotation.Resource;
+
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -17,9 +20,14 @@ import com.goafanti.common.dao.JtCollectSearchMapper;
 import com.goafanti.common.dao.OrganizationIdentityMapper;
 import com.goafanti.common.dao.UserIdentityMapper;
 import com.goafanti.common.dao.UserMapper;
+import com.goafanti.common.enums.VoucherSourceType;
 import com.goafanti.common.model.JtCollectSearch;
+import com.goafanti.common.model.JtVoucherDetail;
 import com.goafanti.common.model.User;
+import com.goafanti.common.utils.InvitationCodeUtils;
+import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.JDBCIdGenerator;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.user.bo.OrgUnitNames;
@@ -29,6 +37,8 @@ import com.goafanti.user.bo.UserNames;
 import com.goafanti.user.bo.UserPageHomeBo;
 import com.goafanti.user.bo.UserPartnerDetailBo;
 import com.goafanti.user.service.UserService;
+import com.goafanti.voucher.service.VoucherDetailService;
+import com.goafanti.voucher.service.VoucherService;
 
 @Service
 public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserService {
@@ -40,6 +50,12 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 	private UserIdentityMapper				userIdentityMapper;
 	@Autowired
 	private JtCollectSearchMapper 		jtCollectSearchMapper;
+	@Autowired
+	private VoucherService		voucherService;
+	@Autowired
+	private VoucherDetailService	voucherDetailService;
+	@Resource
+	private JDBCIdGenerator	jDBCIdGenerator;
 	@Value(value="${collect_flag}")
 	private boolean collectFlag;
 	@Override
@@ -246,4 +262,44 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 	public int getCountByMobile(String id,String mobile) {
 		return userMapper.getCountByMobile(id,mobile);
 	}
+
+	@Override
+	public String updateGetInvitationCode(String uid) {
+		String str=userMapper.getInvitationCode(uid);
+		if (str==null) {
+			str=InvitationCodeUtils.toSerialCode(new Date().getTime());
+			User u=new User();
+			u.setId(uid);
+			u.setToInviteCode(str);
+			userMapper.updateByPrimaryKeySelective(u);
+		}
+		return str;
+	}
+
+	@Override
+	public void getVoucher(User us) {
+		if (StringUtils.isNotBlank(us.getBeInviteCode())) {
+			List<String> ids=voucherService.getSourceVoucher(VoucherSourceType.BYQFWS.getCode());
+			for (String s : ids) {
+				JtVoucherDetail j=new JtVoucherDetail();
+				j.setId(jDBCIdGenerator.generateId().toString());
+				j.setReceiveTime(new Date());
+				j.setVoucherId(s);
+				j.setUseUid(us.getId());
+				j.setStatus(0);
+				voucherDetailService.saveVoucherDetail(j);
+			}
+			User toUser=userMapper.getToInviteCode(us.getBeInviteCode());
+			List<String> ids2=voucherService.getSourceVoucher(VoucherSourceType.YQFWS.getCode());
+			for (String string : ids2) {
+				JtVoucherDetail j=new JtVoucherDetail();
+				j.setId(jDBCIdGenerator.generateId().toString());
+				j.setReceiveTime(new Date());
+				j.setVoucherId(string);
+				j.setUseUid(toUser.getId());
+				j.setStatus(0);
+				voucherDetailService.saveVoucherDetail(j);
+			}
+		}
+	}
 }

+ 4 - 12
src/main/java/com/goafanti/voucher/controller/AdminVoucherController.java

@@ -25,22 +25,20 @@ public class AdminVoucherController extends CertifyApiController {
 	 public Result saveVoucher(JtVoucher voucher ){
 		 Result result=new Result();
 		 chack(voucher, result);
-		 if (!result.getError().isEmpty()) {
-			 return result;	
-		}
+		 if (!result.getError().isEmpty())return result;	
 		 result.data(voucherService.saveVoucher(voucher));
 		 return result;
 	 }
 	 @RequestMapping(value = "/update" ,method=RequestMethod.POST)
 	 public Result updateVoucher(JtVoucher voucher ){
 		 Result result=new Result();
-		 chack(voucher, result);
+		 /*chack(voucher, result);
 		 if (!result.getError().isEmpty()) {
 			 return result;	
 		}
 		 if(voucher.getActiveState()==null) {
 	    		result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"活动标识","活动标识"));return result;
-	    	}
+	    	}*/
 		 result.data(voucherService.updateVoucher(voucher));
 		 return result;
 	 }
@@ -62,13 +60,7 @@ public class AdminVoucherController extends CertifyApiController {
 		 result.data(voucherService.selectVoucherList(name, limitUse, activeState, source, pageNo, pageSize));
 		 return result;
 	 }
-	 
-	
-	 
-
-
-
-	private Result chack(JtVoucher voucher, Result result) {
+	 private Result chack(JtVoucher voucher, Result result) {
 		
 		if(StringUtils.isBlank(voucher.getName())) {
 	    		result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"名称","名称"));return result;

+ 3 - 2
src/main/java/com/goafanti/voucher/controller/AdminVoucherDetailController.java

@@ -58,9 +58,10 @@ public class AdminVoucherDetailController extends CertifyApiController {
 	
 	 
 	 @RequestMapping(value = "/selectList" ,method=RequestMethod.GET)
-	 public Result selectVoucherDetailList(String name,Integer status,String userMobile,Integer source,Integer pageNo,Integer pageSize){
+	 public Result selectVoucherDetailList(String name,Integer status,String userMobile,Integer source,
+			 Integer sort,Integer sortType,Integer pageNo,Integer pageSize){
 		 Result result=new Result();
-		 result.data(voucherDetailService.selectVoucherDetailList(name, status, userMobile,source, pageNo, pageSize));
+		 result.data(voucherDetailService.selectVoucherDetailList(name, status, userMobile,source,sort, sortType, pageNo, pageSize));
 		 return result;
 	 }
 	 

+ 91 - 0
src/main/java/com/goafanti/voucher/controller/UserVoucherController.java

@@ -0,0 +1,91 @@
+package com.goafanti.voucher.controller;
+
+import javax.annotation.Resource;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.controller.CertifyApiController;
+import com.goafanti.common.model.JtVoucher;
+import com.goafanti.common.utils.StringUtils;
+import com.goafanti.voucher.service.VoucherDetailService;
+import com.goafanti.voucher.service.VoucherService;
+
+@RestController
+@RequestMapping(value = "/open/api/user/voucher")
+public class UserVoucherController extends CertifyApiController {
+	 @Resource
+	 private VoucherService		voucherService;
+	 @Resource
+	 private VoucherDetailService	voucherDetailService;
+	
+
+	 
+	 
+	 @RequestMapping(value = "/save" ,method=RequestMethod.POST)
+	 public Result saveVoucher(JtVoucher voucher ){
+		 Result result=new Result();
+		 chack(voucher, result);
+		 if (!result.getError().isEmpty())return result;	
+		 result.data(voucherService.saveVoucher(voucher));
+		 return result;
+	 }
+	 @RequestMapping(value = "/update" ,method=RequestMethod.POST)
+	 public Result updateVoucher(JtVoucher voucher ){
+		 Result result=new Result();
+		 /*chack(voucher, result);
+		 if (!result.getError().isEmpty()) {
+			 return result;	
+		}
+		 if(voucher.getActiveState()==null) {
+	    		result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"活动标识","活动标识"));return result;
+	    	}*/
+		 result.data(voucherService.updateVoucher(voucher));
+		 return result;
+	 }
+	 @RequestMapping(value = "/delect" ,method=RequestMethod.POST)
+	 public Result delectVoucher(String  id ){
+		 Result result=new Result();
+		 result.data(voucherService.delectVoucher(id));
+		 return result;
+	 }
+	 @RequestMapping(value = "/select" ,method=RequestMethod.GET)
+	 public Result selectVoucher(String  id ){
+		 Result result=new Result();
+		 result.data(voucherService.selectVoucher(id));
+		 return result;
+	 }
+	 @RequestMapping(value = "/selectList" ,method=RequestMethod.GET)
+	 public Result selectVoucherList(String name,Integer limitUse,Integer activeState,Integer source,Integer pageNo,Integer pageSize){
+		 Result result=new Result();
+		 result.data(voucherService.selectVoucherList(name, limitUse, activeState, source, pageNo, pageSize));
+		 return result;
+	 }
+	 @RequestMapping(value = "/selectDetailList" ,method=RequestMethod.GET)
+	 public Result selectVoucherDetailList(String name,Integer status,String userMobile,Integer source,
+			 Integer sort,Integer sortType,Integer pageNo,Integer pageSize){
+		 Result result=new Result();
+		 result.data(voucherDetailService.selectVoucherDetailList(name, status, userMobile,source,sort, sortType, pageNo, pageSize));
+		 return result;
+	 }
+	 private Result chack(JtVoucher voucher, Result result) {
+		
+		if(StringUtils.isBlank(voucher.getName())) {
+	    		result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"名称","名称"));return result;
+	    	}
+		 if(voucher.getSource()==null) {
+	    		result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"来源","来源"));return result;
+	    	}
+	    if(voucher.getMoney()==null) {
+	    		result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"面额","面额"));return result;
+	    	}
+	    if(voucher.getDurationDay()==null) {
+	    		result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"使用期限","使用期限"));return result;
+	    	}
+	    
+    
+	    return result;
+	}
+}

+ 1 - 2
src/main/java/com/goafanti/voucher/service/VoucherDetailService.java

@@ -1,6 +1,5 @@
 package com.goafanti.voucher.service;
 
-import com.goafanti.common.model.JtVoucher;
 import com.goafanti.common.model.JtVoucherDetail;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.voucher.bo.JtVoucherDetailListBo;
@@ -14,7 +13,7 @@ public interface VoucherDetailService {
 	
 	JtVoucherDetail selectVoucherDetail(String id);
 	
-	Pagination<JtVoucherDetailListBo> selectVoucherDetailList(String name,Integer limitUse,String userMobile,Integer source,Integer pageNo,Integer pageSize);
+	Pagination<JtVoucherDetailListBo> selectVoucherDetailList(String name,Integer limitUse,String userMobile,Integer source,Integer sort,Integer sortType,Integer pageNo,Integer pageSize);
 	
 	
 }

+ 7 - 2
src/main/java/com/goafanti/voucher/service/impl/VoucherDetailServiceImpl.java

@@ -2,7 +2,6 @@ package com.goafanti.voucher.service.impl;
 
 
 
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -16,9 +15,11 @@ import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.dao.JtVoucherDetailMapper;
 
 import com.goafanti.common.model.JtVoucherDetail;
+import com.goafanti.common.model.User;
 import com.goafanti.common.utils.DateUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.voucher.bo.JtVoucherDetailListBo;
 import com.goafanti.voucher.service.VoucherDetailService;
 @Service
@@ -51,7 +52,7 @@ public class VoucherDetailServiceImpl extends BaseMybatisDao<JtVoucherDetailMapp
 	@SuppressWarnings("unchecked")
 	@Override
 	public Pagination<JtVoucherDetailListBo> selectVoucherDetailList(String name, Integer status, String userMobile,
-			Integer source, Integer pageNo, Integer pageSize) {
+			Integer source,Integer sort,Integer sortType, Integer pageNo, Integer pageSize) {
 		Map<String,Object> params = new HashMap<>();
 		if (pageNo==null||pageNo<1) pageNo=1;
 		if (pageSize==null||pageSize<1) pageSize=10;
@@ -59,6 +60,10 @@ public class VoucherDetailServiceImpl extends BaseMybatisDao<JtVoucherDetailMapp
 		if (null != status) params.put("status", status);
 		if (null != userMobile) params.put("userMobile", userMobile);
 		if (null != source) params.put("source", source);
+		if (null != sort) params.put("sort", sort);
+		if (null != sortType) params.put("sortType", sortType);
+		if(TokenManager.getToken() instanceof User)params.put("uid", TokenManager.getUserId());
+		//params.put("uid", "a8cd3226-2e6e-43c7-b4b0-1b72bd9cfa41");
 		Pagination<JtVoucherDetailListBo> pagination=	(Pagination<JtVoucherDetailListBo>) findPage("selectVoucherDetailList", "selectVoucherDetailCount",params,
 						pageNo, pageSize);
 		List<JtVoucherDetailListBo> list=(List<JtVoucherDetailListBo>) pagination.getList();

+ 8 - 0
src/main/java/com/goafanti/voucher/service/impl/VoucherServiceImpl.java

@@ -12,8 +12,10 @@ import org.springframework.stereotype.Service;
 import com.goafanti.common.dao.JtVoucherMapper;
 import com.goafanti.common.enums.VoucherSourceType;
 import com.goafanti.common.model.JtVoucher;
+import com.goafanti.common.model.User;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.voucher.bo.JtVoucherListBo;
 import com.goafanti.voucher.service.VoucherService;
 @Service
@@ -25,6 +27,10 @@ public class VoucherServiceImpl extends BaseMybatisDao<JtVoucherMapper> implemen
 	public int saveVoucher(JtVoucher v) {
 		v.setId(UUID.randomUUID().toString());
 		v.setActiveState(1);//活动进行中
+		if (TokenManager.getToken() instanceof User&&TokenManager.getUserId()!=null) {
+			v.setGrantingUid(TokenManager.getUserId());
+		}
+		v.setGrantingUid("a8cd3226-2e6e-43c7-b4b0-1b72bd9cfa41");
 		return jtVoucherMapper.insertSelective(v);
 	}
 
@@ -54,6 +60,8 @@ public class VoucherServiceImpl extends BaseMybatisDao<JtVoucherMapper> implemen
 		if (null != limitUse) params.put("limitUse", limitUse);
 		if (null != activeState) params.put("activeState", activeState);
 		if (null != source) params.put("source", source);
+		if(TokenManager.getToken() instanceof User)params.put("uid", TokenManager.getUserId());
+		//params.put("uid", "1");
 		return (Pagination<JtVoucherListBo>) findPage("selectVoucherList", "selectVoucherCount",params,
 				pageNo, pageSize);
 	}

+ 2 - 2
src/main/resources/props/config_local.properties

@@ -55,9 +55,9 @@ app.name=AFT
 app.mobile.website=http://m.kedexinxi.com
 template.cacheable=false
 
-static.host=//sclient.jishutao.com:8088/client/1.0.0
+static.host=//sclient.jishutao.com:80/client/1.0.0
 
-portal.host=//sportal.jishutao.com:80/portal/1.0.1
+portal.host=//sportal.jishutao.com:8088/portal/1.0.1
 
 avatar.host=//sclient.jishutao.com
 avatar.upload.host=//sclient.jishutao.com/upload