姜永辉 пре 1 година
родитељ
комит
8a4c03e8bd

+ 6 - 0
src/main/java/com/dk/oauth/model/VO/integral/IntegralShareVO.java

@@ -98,6 +98,12 @@ public class IntegralShareVO {
     @ApiModelProperty(value = "积分类型 (【系统字典】注册;签到;分享;使用)")
     private String integralType;
 
+    /**
+     * 员工
+     */
+    @ApiModelProperty(value = "员工")
+    private String staffName;
+
 
     /*
      * 相关属性

+ 38 - 0
src/main/java/com/dk/oauth/service/integral/IntegralShareService.java

@@ -8,13 +8,18 @@ import com.dk.common.model.pojo.PageList;
 import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
 import com.dk.oauth.infrastructure.convert.integral.IntegralShareConvert;
+import com.dk.oauth.mapper.integral.IntegralItemMapper;
+import com.dk.oauth.mapper.integral.IntegralMapper;
 import com.dk.oauth.mapper.integral.IntegralTacticMapper;
 import com.dk.oauth.model.VO.integral.CouponSendVO;
 import com.dk.oauth.model.VO.integral.IntegralShareVO;
+import com.dk.oauth.model.pojo.integral.Integral;
+import com.dk.oauth.model.pojo.integral.IntegralItem;
 import com.dk.oauth.model.pojo.integral.IntegralShare;
 import com.dk.oauth.mapper.integral.IntegralShareMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.oauth.model.pojo.integral.IntegralTactic;
 import com.dk.oauth.model.query.integral.IntegralQuery;
 import com.dk.oauth.model.query.integral.IntegralShareQuery;
 import com.dk.oauth.model.query.integral.IntegralTacticQuery;
@@ -48,6 +53,11 @@ public class IntegralShareService extends BaseService<IntegralShare> {
 	//积分策略
 	private IntegralTacticMapper integralTacticMapper;
 
+	@Autowired
+	private IntegralMapper integralMapper;
+	@Autowired
+	private IntegralItemMapper integralItemMapper;
+
 
 	/**
 	 * @desc   : 条件查询
@@ -83,6 +93,7 @@ public class IntegralShareService extends BaseService<IntegralShare> {
 			//积分策略不存在
 			throw new BaseBusinessException(ErrorCodeEnum.INTEGRAL_TACTIC_EXIST.getCode(), ErrorCodeEnum.INTEGRAL_TACTIC_EXIST.getMessage());
 		}
+		IntegralTacticResponse integralTactic = integralTacticResponses.get(0);
 		//每日分享次数
 		Integer shareDayNum = integralTacticResponses.get(0).getShareDayNum();
 		//endregion
@@ -118,6 +129,33 @@ public class IntegralShareService extends BaseService<IntegralShare> {
 				//当日已无可分享次数
 				throw new BaseBusinessException(ErrorCodeEnum.HERE_ARE_NO_MORE_SHAREABLE_TIMES_ON_THAT_DAY.getCode(), ErrorCodeEnum.HERE_ARE_NO_MORE_SHAREABLE_TIMES_ON_THAT_DAY.getMessage());
 			}
+
+			//
+			// 积分明细
+			IntegralItem integralItem = new IntegralItem();
+			integralItem.setIntegralType(Constant.IntegralType.INTEGRAL_TYPE_REGISTER.getName());
+			integralItem.setIntegral(integralTactic.getShareIntegral());
+			integralItem.setCpId(integralShareVO.getCpId());
+			integralItem.setAccDate(LocalDateTime.now());
+			integralItem.setUserId(integralShareVO.getUserId());
+			integralItem.setStaffName(integralShareVO.getStaffName());
+			integralItemMapper.insert(integralItem);
+			// 积分 新公司的
+			Integral integral = new Integral();
+			integral.setCpId(integralShareVO.getCpId());
+			integral.setFlgValid(true);
+			IntegralQuery integralQuery = new IntegralQuery();
+			integralQuery.setCpId(integralShareVO.getCpId());
+			integralQuery.setFlgValid(true);
+			List<IntegralResponse> integralResponses = integralMapper.selectByCond(integralQuery);
+			if (integralResponses != null && integralResponses.size() > 0) {
+				integral.setIntegral(integralTactic.getShareIntegral()  );
+				integralMapper.updateById(integral);
+			}else{
+				integral.setIntegral(integralTactic.getShareIntegral());
+				integralMapper.insert(integral);
+			}
+
 			//endregion
 		}
 		//endregion