commit
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
package io.v.nutz.zhgh.mobile.welfare;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.wizzer.framework.page.Pagination;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.result.Result;
|
||||
import io.v.nutz.base.service.SimpleService;
|
||||
import io.v.nutz.base.utils.DateUtil;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.utils.Vi;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.welfare.mode.WelfareProvideMode;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareList;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProject;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProjectSubject;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProjectSubjectOption;
|
||||
@@ -28,6 +31,7 @@ import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -178,5 +182,31 @@ public class MWelfareController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户积分是否满足
|
||||
*
|
||||
* @param projectId
|
||||
* @param totalIntegral
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
public Result validateUserIntegral(String projectId, String totalIntegral) {
|
||||
BigDecimal totalIntegralBig = new BigDecimal(totalIntegral);
|
||||
if (StrUtil.isBlank(projectId)) {
|
||||
return Result.error("数据错误!");
|
||||
}
|
||||
WelfareList welfareList = dao.fetch(WelfareList.class, Cnd.where("projectId", "=", projectId).and("userId", "=", ShiroUtil.getPrincipalProperty("id")));
|
||||
if (welfareList == null) {
|
||||
return Result.error("您暂无此福利!");
|
||||
}
|
||||
WelfareProject project = simpleService.dao().fetch(WelfareProject.class, projectId);
|
||||
|
||||
totalIntegralBig = totalIntegralBig.divide(BigDecimal.valueOf(100));
|
||||
if (project.getAllIntegral().compareTo(totalIntegralBig) < 0) {
|
||||
return Result.error("您的积分不足!");
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ public class ShoppingTypeApplyController {
|
||||
ShoppingType shoppingType = baseService.dao().fetch(ShoppingType.class, shoppingId);
|
||||
for (WelfareProjectSubjectOption option : welfareProjectSubjectOption) {
|
||||
// option.setShoppingName(shoppingType.getShoppingName());
|
||||
// option.setShoppingId(shoppingId);
|
||||
option.setShoppingId(shoppingId);
|
||||
option.setOptionType("套餐");
|
||||
option.setSubjectId(projectSubject.getId());
|
||||
}
|
||||
@@ -254,13 +254,35 @@ public class ShoppingTypeApplyController {
|
||||
|
||||
|
||||
String SqlChooseUserByStoreId = """
|
||||
SELECT
|
||||
su.id,su.username,su.loginname,wpus.selectTime,su.unionname
|
||||
FROM
|
||||
`welfare_project_user_selection` wpus
|
||||
LEFT JOIN welfare_project wp ON wpus.welfareId=wp.id
|
||||
LEFT JOIN welfare_project_subject_option wpso ON wpus.selectOptionId = wpso.id
|
||||
LEFT JOIN `user` su ON su.id=wpus.selectUserId
|
||||
SELECT
|
||||
CASE
|
||||
|
||||
WHEN
|
||||
wus.selectUserId IS NOT NULL THEN
|
||||
1 ELSE 0
|
||||
END AS isChoose,
|
||||
wl.id,
|
||||
wl.unionid,
|
||||
wl.username,
|
||||
wl.loginname,
|
||||
wl.personType,
|
||||
wl.userState,
|
||||
wl.unionname,
|
||||
wl.unitname,
|
||||
wl.listId,
|
||||
wus.userSign,
|
||||
wus.courierNumber,
|
||||
GROUP_CONCAT( DISTINCT
|
||||
IF
|
||||
( wus.receiveAddress IS NOT NULL AND wus.receiveAddress != '', wus.receiveAddress, '' )
|
||||
) AS receiveAddress,
|
||||
GROUP_CONCAT( DISTINCT wuso.optionName, '(', wus.selectNum, '份)' ) AS gist_list
|
||||
FROM
|
||||
view_welfare_list wl
|
||||
LEFT JOIN welfare_project_user_selection wus ON wus.welfareId = wl.projectId
|
||||
AND wus.selectUserId = wl.id
|
||||
LEFT JOIN welfare_project_subject_option wuso ON wus.selectOptionId = wuso.id
|
||||
LEFT JOIN welfare_project wp ON wp.id = wus.welfareId
|
||||
$condition
|
||||
""";
|
||||
|
||||
@@ -278,40 +300,15 @@ public class ShoppingTypeApplyController {
|
||||
|
||||
Sql sql = Sqls.create(SqlChooseUserByStoreId);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("wpso.shoppingId", "=", id);
|
||||
cnd.and("wuso.shoppingId", "=", id);
|
||||
cnd.andEX("wp.schoolWelfareId", "=", schoolWelfareId);
|
||||
cnd.and("wp.choiceTimeEnd", "<", DateUtil.now());
|
||||
cnd.andEX("su.unionId", "=", unionId);
|
||||
cnd.groupBy("su.id");
|
||||
cnd.asc("wpso.optionName");
|
||||
cnd.asc("su.loginname");
|
||||
cnd.andEX("wl.unionId", "=", unionId);
|
||||
cnd.groupBy("wl.id");
|
||||
cnd.asc("wuso.optionName");
|
||||
cnd.asc("wl.loginname");
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = baseService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
|
||||
List<NutMap> list = pagination.getList();
|
||||
list.forEach(v -> {
|
||||
Sql sql_gift = Sqls.create("""
|
||||
select wpus.id,wpso.optionName,wpus.receiveAddress from welfare_project_user_selection wpus
|
||||
left join welfare_project_subject_option wpso on wpso.id = wpus.selectOptionId
|
||||
where wpus.selectUserId = @uid and wpso.shoppingId=@shoppingId
|
||||
""");
|
||||
sql_gift.setParam("uid", v.getString("id"));
|
||||
sql_gift.setParam("shoppingId", id);
|
||||
List<NutMap> gift_list = baseService.listMap(sql_gift);
|
||||
if (Lang.isNotEmpty(gift_list)) {
|
||||
v.put("gist_list", gift_list.stream().map(x -> x.getString("optionName")).collect(Collectors.joining("、")));
|
||||
|
||||
if (!gift_list.stream().findFirst().get().getString("receiveAddress").contains("undefined")) {
|
||||
v.put("receiveAddress", gift_list.stream().findFirst().get().getString("receiveAddress"));
|
||||
} else {
|
||||
v.put("receiveAddress", "");
|
||||
}
|
||||
} else {
|
||||
v.put("gist_list", "");
|
||||
v.put("receiveAddress", "");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return pagination;
|
||||
|
||||
}
|
||||
@@ -323,37 +320,15 @@ public class ShoppingTypeApplyController {
|
||||
|
||||
Sql sql = Sqls.create(SqlChooseUserByStoreId);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("wpso.shoppingId", "=", id);
|
||||
cnd.and("wuso.shoppingId", "=", id);
|
||||
cnd.andEX("wp.schoolWelfareId", "=", schoolWelfareId);
|
||||
cnd.and("wp.choiceTimeEnd", "<", DateUtil.now());
|
||||
cnd.andEX("su.unionId", "=", unionId);
|
||||
cnd.groupBy("su.id");
|
||||
cnd.asc("wpso.optionName");
|
||||
cnd.asc("su.loginname");
|
||||
cnd.andEX("wl.unionId", "=", unionId);
|
||||
cnd.groupBy("wl.id");
|
||||
cnd.asc("wuso.optionName");
|
||||
cnd.asc("wl.loginname");
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = baseService.listMap(sql);
|
||||
list.forEach(v -> {
|
||||
Sql sql_gift = Sqls.create("""
|
||||
select wpus.id,wpso.optionName,wpus.receiveAddress from welfare_project_user_selection wpus
|
||||
left join welfare_project_subject_option wpso on wpso.id = wpus.selectOptionId
|
||||
where wpus.selectUserId = @uid and wpso.shoppingId=@shoppingId
|
||||
""");
|
||||
sql_gift.setParam("uid", v.getString("id"));
|
||||
sql_gift.setParam("shoppingId", id);
|
||||
List<NutMap> gift_list = baseService.listMap(sql_gift);
|
||||
if (Lang.isNotEmpty(gift_list)) {
|
||||
v.put("gist_list", gift_list.stream().map(x -> x.getString("optionName")).collect(Collectors.joining("、")));
|
||||
|
||||
if (!gift_list.stream().findFirst().get().getString("receiveAddress").contains("undefined")) {
|
||||
v.put("receiveAddress", gift_list.stream().findFirst().get().getString("receiveAddress"));
|
||||
} else {
|
||||
v.put("receiveAddress", "");
|
||||
}
|
||||
} else {
|
||||
v.put("gist_list", "");
|
||||
v.put("receiveAddress", "");
|
||||
}
|
||||
});
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
entityList.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
|
||||
@@ -191,6 +191,7 @@ public class WelfareProjectMangeController {
|
||||
optionChain.add("isSystemDefault", o.getIsSystemDefault());
|
||||
optionChain.add("optionSort", o.getOptionSort());
|
||||
optionChain.add("imgUrl", o.getImgUrl());
|
||||
optionChain.add("integral", o.getIntegral());
|
||||
optionChain.add("description", o.getDescription());
|
||||
optionChain.add("shoppingId", o.getShoppingId());
|
||||
optionChain.add("shoppingName", o.getShoppingName());
|
||||
@@ -234,7 +235,6 @@ public class WelfareProjectMangeController {
|
||||
// }
|
||||
}
|
||||
dao.update(project);
|
||||
|
||||
}
|
||||
|
||||
dao.clear(WelfareMemberUnionConfirm.class, Cnd.where("projectId","=",project.getId()));
|
||||
|
||||
@@ -11,6 +11,7 @@ import io.v.nutz.sys.services.SysUserService;
|
||||
import io.v.nutz.web.commons.slog.annotation.SLog;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareList;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareProject;
|
||||
import io.v.nutz.zhgh.welfare.model.WelfareUserSelection;
|
||||
import io.v.nutz.zhgh.welfare.service.WelfareProjectService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
@@ -29,6 +30,7 @@ import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -107,7 +109,7 @@ public class WelfareUserChooseController {
|
||||
@SLog(type = "welfare", tag = "pc电脑选福利", msg = "福利")
|
||||
@RequiresPermissions("welfare.user.choose")
|
||||
public Object doChoose(String chooseIds, String projectId, String subjectId, String receiveAddress,
|
||||
@Param(value = "mobile",required = false) String mobile) {
|
||||
@Param(value = "mobile", required = false) String mobile) {
|
||||
try {
|
||||
lock.lock();
|
||||
String userId = ShiroUtil.getUserId();
|
||||
@@ -159,15 +161,44 @@ public class WelfareUserChooseController {
|
||||
@SLog(type = "welfare", tag = "选择福利", msg = "福利")
|
||||
@RequiresPermissions("welfare.user.choose")
|
||||
public Result confirmSelect(@Param("welfareUserSelections") WelfareUserSelection[] welfareUserSelections,
|
||||
String projectId, @Param(value = "mobile",required = false) String mobile) {
|
||||
String totalIntegral,
|
||||
String projectId, @Param(value = "mobile", required = false) String mobile) {
|
||||
|
||||
try {
|
||||
lock.lock();
|
||||
WelfareProject project = simpleService.dao().fetch(WelfareProject.class, projectId);
|
||||
// 获取当前时间
|
||||
Date now = new Date();
|
||||
// 判断时间段是否已结束
|
||||
if (now.after(project.getProvideTimeEnd())) {
|
||||
return Result.error("您选择的时间段已结束!");
|
||||
}
|
||||
|
||||
// 判断时间段是否尚未开始
|
||||
if (now.before(project.getProvideTimeStart())) {
|
||||
return Result.error("您选择的时间段尚未开始!");
|
||||
}
|
||||
String userId = ShiroUtil.getUserId();
|
||||
|
||||
int count = simpleService.dao().count(WelfareList.class, Cnd.where("projectId", "=", projectId).and("userId", "=", userId));
|
||||
if (count <= 0) {
|
||||
return Result.error("您不在此次选择名单中,如有疑问请及时联系校工会");
|
||||
WelfareList welfareList = simpleService.dao().fetch(WelfareList.class, Cnd.where("projectId", "=", projectId).and("userId", "=", ShiroUtil.getUserId()));
|
||||
if (Lang.isEmpty(welfareList)) {
|
||||
return Result.error("您暂无权限!");
|
||||
}
|
||||
|
||||
//如果是积分模式
|
||||
if (project.getIsIntegralMode()) {
|
||||
BigDecimal totalIntegralBig = new BigDecimal(totalIntegral);
|
||||
totalIntegralBig = totalIntegralBig.divide(BigDecimal.valueOf(100));
|
||||
if (totalIntegralBig.compareTo(BigDecimal.ZERO) == 0) {
|
||||
return Result.error("请选择后在提交!");
|
||||
}
|
||||
if (project.getAllIntegral().compareTo(totalIntegralBig) < 0) {
|
||||
return Result.error("您的积分不足!");
|
||||
}
|
||||
if (totalIntegralBig.compareTo(project.getAllIntegral()) < 0) {
|
||||
BigDecimal remainingIntegral = project.getAllIntegral().subtract(totalIntegralBig);
|
||||
return Result.error("您积分还剩余" + remainingIntegral + ",请选择后再提提交!");
|
||||
}
|
||||
}
|
||||
|
||||
//删除上次选择的
|
||||
@@ -178,7 +209,7 @@ public class WelfareUserChooseController {
|
||||
for (WelfareUserSelection welfareUserSelection : welfareUserSelections) {
|
||||
welfareUserSelection.setSelectUserId(userId);
|
||||
welfareUserSelection.setSelectTime(new Date());
|
||||
if (welfareUserSelection.getSelectNum() > 1) {
|
||||
if (welfareUserSelection.getSelectNum() > 1 && !project.getIsIntegralMode()) {
|
||||
return Result.error("福利选择限制超过最大限制");
|
||||
}
|
||||
}
|
||||
@@ -195,7 +226,7 @@ public class WelfareUserChooseController {
|
||||
}
|
||||
|
||||
return Result.success("选择成功");
|
||||
} catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error();
|
||||
} finally {
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -219,6 +220,17 @@ public class WelfareProject extends BaseModel implements Serializable, SysHomeCo
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean isYearBirthday;
|
||||
|
||||
@Column
|
||||
@Comment("是否积分模式")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean isIntegralMode;
|
||||
|
||||
@Column
|
||||
@Comment("总积分")
|
||||
@Default("0")
|
||||
@ColDefine(customType = "decimal(10,2)")
|
||||
private BigDecimal allIntegral;
|
||||
|
||||
@Column
|
||||
@Comment("是否禁用")
|
||||
@Default("0")
|
||||
|
||||
@@ -89,4 +89,10 @@ public class WelfareProjectSubjectOption extends BaseModel {
|
||||
@Comment("简短备注")
|
||||
@ColDefine(type = ColType.VARCHAR,width = 100)
|
||||
private String simpleDesc;
|
||||
|
||||
@Column
|
||||
@Comment("套餐积分")
|
||||
@Default("0")
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Integer integral;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user