New file |
| | |
| | | package com.yeshi.fanli.controller.admin;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.net.URLDecoder;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.common.AdminUser;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackExchange;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
|
| | | import com.yeshi.fanli.service.AdminUserService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackExchangeService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/redpack")
|
| | | public class RedPackAdminController {
|
| | |
|
| | | @Resource
|
| | | private RedPackExchangeService redPackExchangeService;
|
| | | |
| | | @Resource
|
| | | private RedPackBalanceService redPackBalanceService;
|
| | | |
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | | |
| | | @Resource
|
| | | private AdminUserService adminUserService;
|
| | | |
| | |
|
| | | /**
|
| | | * |
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param key 搜索:暂只提供uid
|
| | | * @param state 状态:
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "query")
|
| | | public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, PrintWriter out) {
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | |
|
| | | try {
|
| | | List<RedPackExchange> list = redPackExchangeService.query((pageIndex - 1) * pageSize, pageSize, key, state);
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | | |
| | | for (RedPackExchange redPackExchange: list) {
|
| | | UserInfo userInfo = userInfoService.selectByPKey(redPackExchange.getUid());
|
| | | redPackExchange.setPortrait(userInfo.getPortrait());
|
| | | redPackExchange.setNickName(userInfo.getNickName());
|
| | | |
| | | Long auditId = redPackExchange.getAuditId();
|
| | | if(auditId != null) {
|
| | | AdminUser adminUser = adminUserService.selectByPrimaryKey(auditId);
|
| | | if (adminUser != null) {
|
| | | redPackExchange.setAuditName(adminUser.getName());
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | long count = redPackExchangeService.count(key, state);
|
| | |
|
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | | gsonBuilder.serializeNulls();
|
| | | Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", gson.toJson(list));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 获取申请信息
|
| | | * @param callback
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getApplyInfo")
|
| | | public void getAuditInfo(String callback, Long id, PrintWriter out) {
|
| | | RedPackExchange exchange = redPackExchangeService.selectByPrimaryKey(id);
|
| | | if (exchange == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("申请记录不存在"));
|
| | | return;
|
| | | }
|
| | | Long uid = exchange.getUid();
|
| | | BigDecimal balance = redPackBalanceService.getBalance(uid);
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | List<Long> listCount = redPackExchangeService.countState(uid);
|
| | | List<BigDecimal> listMoney = redPackExchangeService.countMoneyState(uid);
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("exchange", exchange);
|
| | | data.put("userInfo", userInfo);
|
| | | |
| | | data.put("countInit", listCount.get(0));
|
| | | data.put("countSucceed", listCount.get(1));
|
| | | data.put("countReject", listCount.get(2));
|
| | | |
| | | data.put("balance", balance);
|
| | | data.put("moneyInit", listMoney.get(0));
|
| | | data.put("moneySucceed", listMoney.get(1));
|
| | | data.put("moneyReject", listMoney.get(2));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | /**
|
| | | * 允许提现
|
| | | * @param callback
|
| | | * @param id
|
| | | * @param code
|
| | | * @param out
|
| | | * @param request
|
| | | */
|
| | | @RequestMapping(value = "passExchange")
|
| | | public void passExchange(String callback, Long id, String code, PrintWriter out, HttpServletRequest request) {
|
| | | try {
|
| | | /* 检验是否登陆 */
|
| | | AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
|
| | | if (admin == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。"));
|
| | | return;
|
| | | }
|
| | | |
| | | /* 检验是否通过验证 */
|
| | | String codeType = (String) request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT);
|
| | | if (!"1".equals(codeType)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(3, "邮箱验证未通过"));
|
| | | return;
|
| | | }
|
| | | |
| | | /* 允许提现 操作 */
|
| | | redPackExchangeService.passExchange(id, admin);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
|
| | | } catch (RedPackExchangeException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | return;
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 拒绝提现
|
| | | * @param callback
|
| | | * @param id
|
| | | * @param code
|
| | | * @param reason
|
| | | * @param out
|
| | | * @param request
|
| | | */
|
| | | @RequestMapping(value = "rejectExchange")
|
| | | public void rejectExchange(String callback, Long id, String code, String reason, PrintWriter out,
|
| | | HttpServletRequest request) {
|
| | | try {
|
| | | /* 检验是否登陆 */
|
| | | AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
|
| | | if (admin == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆"));
|
| | | return;
|
| | | }
|
| | | |
| | | /* 检验是否通过验证 */
|
| | | String codeType = (String) request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT);
|
| | | if (!"1".equals(codeType)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(3, "邮箱验证未通过"));
|
| | | return;
|
| | | }
|
| | | // 编码转换
|
| | | reason = URLDecoder.decode(reason, "UTF-8");
|
| | | |
| | | redPackExchangeService.rejectExchange(id, reason, admin);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("拒绝成功"));
|
| | | } catch (RedPackExchangeException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | return;
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.JsonElement;
|
| | | import com.google.gson.JsonPrimitive;
|
| | | import com.google.gson.JsonSerializationContext;
|
| | | import com.google.gson.JsonSerializer;
|
| | | import com.google.gson.TypeAdapter;
|
| | | import com.google.gson.stream.JsonReader;
|
| | | import com.google.gson.stream.JsonWriter;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackExchange;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackExchangeService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackGiveRecordService;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.vo.redpack.RedPackDetailVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/v2/redpack")
|
| | | public class RedPackControllerV2 {
|
| | |
|
| | | @Resource
|
| | | private RedPackConfigService redPackConfigService;
|
| | |
|
| | | @Resource
|
| | | private RedPackBalanceService redPackBalanceService;
|
| | |
|
| | | @Resource
|
| | | private RedPackDetailService redPackDetailService;
|
| | | |
| | | @Resource |
| | | private RedPackGiveRecordService redPackGiveRecordService;
|
| | | |
| | | @Resource |
| | | private RedPackExchangeService redPackExchangeService;
|
| | |
|
| | | /**
|
| | | * 统计淘礼金
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "countInfo", method = RequestMethod.POST)
|
| | | public void countInfo(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | BigDecimal zero = new BigDecimal(0);
|
| | | BigDecimal todayWin = zero;
|
| | | BigDecimal yesterdayWin = zero;
|
| | | BigDecimal thisMonthWin = zero;
|
| | | BigDecimal lastMonthWin = zero;
|
| | |
|
| | | BigDecimal todayUse = zero;
|
| | | BigDecimal yesterdayUse = zero;
|
| | | BigDecimal thisMonthUse = zero;
|
| | | BigDecimal lastMonthUse = zero;
|
| | | BigDecimal balance = redPackBalanceService.getBalance(uid);
|
| | | if (balance == null) {
|
| | | balance = zero;
|
| | | } else {
|
| | | // 获得
|
| | | todayWin = redPackDetailService.countAddMoneyByDate(uid, 1);
|
| | | yesterdayWin = redPackDetailService.countAddMoneyByDate(uid, 2);
|
| | | thisMonthWin = redPackDetailService.countAddMoneyByDate(uid, 3);
|
| | | lastMonthWin = redPackDetailService.countAddMoneyByDate(uid, 4);
|
| | |
|
| | | // 消耗
|
| | | todayUse = redPackDetailService.countUseMoneyByDate(uid, 1);
|
| | | if (todayUse == null || todayUse.compareTo(zero) > 0) {
|
| | | todayUse = zero;
|
| | | }
|
| | |
|
| | | yesterdayUse = redPackDetailService.countUseMoneyByDate(uid, 2);
|
| | | if (yesterdayUse == null || yesterdayUse.compareTo(zero) > 0) {
|
| | | yesterdayUse = zero;
|
| | | }
|
| | | thisMonthUse = redPackDetailService.countUseMoneyByDate(uid, 3);
|
| | | if (thisMonthUse == null || thisMonthUse.compareTo(zero) > 0) {
|
| | | thisMonthUse = zero;
|
| | | }
|
| | | lastMonthUse = redPackDetailService.countUseMoneyByDate(uid, 4);
|
| | | if (lastMonthUse == null || lastMonthUse.compareTo(zero) > 0) {
|
| | | lastMonthUse = zero;
|
| | | }
|
| | | }
|
| | |
|
| | | List<String> tips = new ArrayList<String>();
|
| | | tips.add("红包余额≥20元后可提现,当前余额不足,请继续加油哦!");
|
| | | tips.add("你也可以选择使用红包,享受给力折扣。");
|
| | | String giveMin = redPackConfigService.getValueByKey("give_money_min");
|
| | | String giveMax = redPackConfigService.getValueByKey("give_money_max");
|
| | | |
| | | // 正在提现金额
|
| | | BigDecimal extractingMoney = redPackExchangeService.countMoneyByState(uid, RedPackExchange.STATE_INIT);
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("balance", balance.setScale(2).toString());
|
| | | data.put("helpLink", redPackConfigService.getValueByKey("desc_help_link"));
|
| | | data.put("giveMin", giveMin);
|
| | | data.put("giveMax", giveMax);
|
| | | data.put("giveDesc", "注:红包赠送金额至少" + giveMin + "元至多" + giveMax + "元");
|
| | |
|
| | | if (extractingMoney != null && extractingMoney.compareTo(zero) > 0) |
| | | data.put("extractingInfo", "提现中:¥" + extractingMoney.setScale(2));
|
| | | |
| | | data.put("extractShortage", tips);
|
| | | data.put("extractMin", redPackConfigService.getValueByKey("extract_money_min"));
|
| | | data.put("extractMax", redPackConfigService.getValueByKey("extract_money_max"));
|
| | | data.put("extractBanlenMin", redPackConfigService.getValueByKey("extract_banlen_min"));
|
| | | data.put("extractDesc", "注:3个工作日内完成审核,红包提现成功后将会进入到余额。");
|
| | | |
| | | data.put("useLink", redPackConfigService.getValueByKey("use_link"));
|
| | |
|
| | | data.put("todayWin", todayWin.setScale(2).toString());
|
| | | data.put("yesterdayWin", yesterdayWin.setScale(2).toString());
|
| | | data.put("thisMonthWin", thisMonthWin.setScale(2).toString());
|
| | | data.put("lastMonthWin", lastMonthWin.setScale(2).toString());
|
| | | data.put("todayUse", todayUse.setScale(2).toString().replaceAll("-", ""));
|
| | | data.put("yesterdayUse", yesterdayUse.setScale(2).toString().replaceAll("-", ""));
|
| | | data.put("thisMonthUse", thisMonthUse.setScale(2).toString().replaceAll("-", ""));
|
| | | data.put("lastMonthUse", lastMonthUse.setScale(2).toString().replaceAll("-", ""));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 明细详情列表
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param index List最末的主键ID
|
| | | * @param year 年份
|
| | | * @param month 月份
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getMoneyDetails")
|
| | | public void getMoneyDetails(AcceptData acceptData, Long uid, Long index, Integer year, Integer month,
|
| | | PrintWriter out) {
|
| | | if (uid == null || uid == 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if ((year == null && month != null) || (year != null && month == null)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "日期不完整"));
|
| | | return;
|
| | | }
|
| | |
|
| | | Date date = null;
|
| | |
|
| | | if (year != null && month != null) {
|
| | | date = new Date(TimeUtil.convertToTimeTemp(year + "-" + month, "yyyy-M"));
|
| | | Calendar ca = Calendar.getInstance();
|
| | | ca.setTime(date);
|
| | | ca.add(Calendar.MONTH, 1);
|
| | | date = new Date(ca.getTimeInMillis() - 1);
|
| | | }
|
| | |
|
| | | // 查询列表
|
| | | List<RedPackDetailVO> list = redPackDetailService.listUserMoneyDetailForClient(uid, index, date);
|
| | | // 统计总条数
|
| | | long count = redPackDetailService.countUserMoneyDetailForClient(uid, index, date);
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | gsonBuilder.registerTypeAdapter(RedPackDetailTypeEnum.class, new TypeAdapter<RedPackDetailTypeEnum>() {
|
| | | @Override
|
| | | public RedPackDetailTypeEnum read(JsonReader arg0) throws IOException {
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void write(JsonWriter out, RedPackDetailTypeEnum arg1) throws IOException {
|
| | | out.beginObject();
|
| | | out.name("portrait").value(arg1.getPicture());
|
| | | out.endObject();
|
| | | }
|
| | | }).registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
|
| | | @Override
|
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | return new JsonPrimitive(TimeUtil.getGernalTime(value.getTime(), "yyyy.MM.dd HH:mm"));
|
| | | }
|
| | | }
|
| | | }).registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
|
| | | @Override
|
| | | public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | // 保留2位小数
|
| | | value = value.setScale(2);
|
| | | return new JsonPrimitive(value.toString());
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | |
|
| | | Gson gson = gsonBuilder.create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("data", gson.toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 赠送红包
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param amount
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "giving", method = RequestMethod.POST)
|
| | | public void giving(AcceptData acceptData, Long uid, BigDecimal amount, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | String tips = redPackGiveRecordService.giving(uid, amount);
|
| | | out.print(JsonUtil.loadTrueResult(tips));
|
| | | } catch (RedPackGiveRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 转换红包为真实金钱
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param amount
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "exchangeCash", method = RequestMethod.POST)
|
| | | public void exchangeCash(AcceptData acceptData, Long uid, BigDecimal amount, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | redPackExchangeService.exchangeCash(uid, amount);
|
| | | out.print(JsonUtil.loadTrueResult("提现申请成功"));
|
| | | } catch (RedPackExchangeException e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.redpack; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.redpack.RedPackBalance; |
| | | |
| | | public interface RedPackBalanceMapper extends BaseMapper<RedPackBalance> { |
| | | |
| | | /** |
| | | * 减掉用户红包金额 |
| | | * @param id |
| | | * @param money |
| | | */ |
| | | void subRedPack(@Param("id") long id, @Param("money") BigDecimal money); |
| | | |
| | | |
| | | /** |
| | | * 增加用户红包金额 |
| | | * @param id |
| | | * @param money |
| | | */ |
| | | void addRedPack(@Param("id") long id, @Param("money") BigDecimal money); |
| | | |
| | | |
| | | /** |
| | | * 查询用于更新余额-锁定 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | RedPackBalance selectForUpdate(long id); |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.redpack; |
| | | |
| | | import java.util.Date; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.redpack.RedPackConfig; |
| | | |
| | | public interface RedPackConfigMapper extends BaseMapper<RedPackConfig> { |
| | | /** |
| | | * 根据key值查询 |
| | | * @param key |
| | | * @return |
| | | */ |
| | | RedPackConfig getByKey(@Param("key") String key,@Param("startTime")Date startTime); |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.redpack; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail; |
| | | import com.yeshi.fanli.vo.redpack.RedPackMonthVO; |
| | | |
| | | public interface RedPackDetailMapper extends BaseMapper<RedPackDetail> { |
| | | |
| | | |
| | | /** |
| | | * 查询明细 |
| | | * @param identifyCode |
| | | * @return |
| | | */ |
| | | RedPackDetail getByIdentifyCode(@Param("identifyCode")String identifyCode); |
| | | |
| | | |
| | | /** |
| | | * 根据日期类型统计获得金额 |
| | | * @param uid |
| | | * @param dateType 1今日 、2昨日、3本月、4上月 |
| | | * @return |
| | | */ |
| | | BigDecimal countAddMoneyByDate(@Param("uid")long uid, @Param("dateType")int dateType); |
| | | |
| | | /** |
| | | * 根据日期类型统计消耗金额 |
| | | * @param uid |
| | | * @param dateType 1今日 、2昨日、3本月、4上月 |
| | | * @return |
| | | */ |
| | | BigDecimal countUseMoneyByDate(@Param("uid")long uid, @Param("dateType")int dateType); |
| | | |
| | | /** |
| | | * 按最大的创建时间和用户ID检索列表 |
| | | * |
| | | * @param uid |
| | | * @param date |
| | | * @return |
| | | */ |
| | | List<RedPackDetail> selectByMaxCreateTime(@Param("uid") Long uid, @Param("date") Date date, @Param("count") int count); |
| | | |
| | | |
| | | /** |
| | | * 通过用户ID和返回的最大时间的详情ID来获取下一页的数据 |
| | | * |
| | | * @param uid |
| | | * @param id |
| | | * @param count |
| | | * @return |
| | | */ |
| | | List<RedPackDetail> selectByUidWithIndexId(@Param("uid") Long uid, @Param("id") Long id, @Param("count") int count); |
| | | |
| | | |
| | | /** |
| | | * 统计某个月份的收入与支出 |
| | | * |
| | | * @param uid |
| | | * @param dateFormat |
| | | * @return |
| | | */ |
| | | List<RedPackMonthVO> selectMonthMoneyByUid(@Param("uid") Long uid, @Param("dateFormat") List<String> dateFormat); |
| | | |
| | | |
| | | /** |
| | | * 获取用户总共有多少记录数据 |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | Long selectCountByUid(@Param("uid") Long uid); |
| | | |
| | | /** |
| | | * 按用户ID和最大时间检索月份的数量 |
| | | * |
| | | * @param uid |
| | | * @param maxDate |
| | | * @return |
| | | */ |
| | | int selectMonthCountByUid(@Param("uid") Long uid, @Param("date") Date maxDate); |
| | | |
| | | |
| | | /** |
| | | * 按最大的创建时间和用户ID检索数量 |
| | | * |
| | | * @param uid |
| | | * @param date |
| | | * @return |
| | | */ |
| | | Long selectCountByUidAndMaxCreateTime(@Param("uid") Long uid, @Param("date") Date date); |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.redpack; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.redpack.RedPackExchange; |
| | | |
| | | public interface RedPackExchangeMapper extends BaseMapper<RedPackExchange> { |
| | | |
| | | /** |
| | | * 查询提现信息 |
| | | * @param start |
| | | * @param count |
| | | * @param key |
| | | * @param state |
| | | * @return |
| | | */ |
| | | List<RedPackExchange> query(@Param("start")Integer start, @Param("count") Integer count, |
| | | @Param("key") String key, @Param("state") Integer state); |
| | | |
| | | Long count(@Param("key") String key, @Param("state") Integer state); |
| | | |
| | | |
| | | /** |
| | | * 统计各个状态 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | List<Long> countState(@Param("uid") long uid); |
| | | |
| | | |
| | | /** |
| | | * 统计各个状态金额 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | List<BigDecimal> countMoneyState(@Param("uid") long uid); |
| | | |
| | | /** |
| | | * 统计状态金额 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | BigDecimal countMoneyByState(@Param("uid") Long uid, @Param("state") Integer state); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.redpack; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.redpack.RedPackGiveRecord; |
| | | |
| | | public interface RedPackGiveRecordMapper extends BaseMapper<RedPackGiveRecord> { |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.entity.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 红包余额
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_red_pack_balance")
|
| | | public class RedPackBalance {
|
| | | // 用户id
|
| | | @Column(name = "rpb_uid")
|
| | | private Long id;
|
| | | // 余额
|
| | | @Column(name = "rpb_money")
|
| | | private BigDecimal money;
|
| | | |
| | | @Column(name = "rpb_create_time")
|
| | | private Date createTime;
|
| | | |
| | | @Column(name = "rpb_update_time")
|
| | | private Date updateTime;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public BigDecimal getMoney() {
|
| | | return money;
|
| | | }
|
| | |
|
| | | public void setMoney(BigDecimal money) {
|
| | | this.money = money;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Date getUpdateTime() {
|
| | | return updateTime;
|
| | | }
|
| | |
|
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.redpack;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 红包配置信息
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_red_pack_config")
|
| | | public class RedPackConfig {
|
| | |
|
| | | @Column(name = "rpc_id")
|
| | | private Long id; |
| | |
|
| | | @Column(name = "rpc_name")
|
| | | private String name; // 名称
|
| | |
|
| | | @Column(name = "rpc_key")
|
| | | private String key; // 唯一值
|
| | |
|
| | | @Column(name = "rpc_value")
|
| | | private String value; // 值
|
| | |
|
| | | @Column(name = "rpc_remark")
|
| | | private String remark; // 备注
|
| | | |
| | | @Column(name = "rpc_start_time")
|
| | | private Date startTime; // 开始使用时间
|
| | |
|
| | | @Column(name = "rpc_create_time")
|
| | | private Date createTime;
|
| | | |
| | | @Column(name = "rpc_update_time")
|
| | | private Date updateTime;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public String getName() {
|
| | | return name;
|
| | | }
|
| | |
|
| | | public void setName(String name) {
|
| | | this.name = name;
|
| | | }
|
| | |
|
| | | public String getKey() {
|
| | | return key;
|
| | | }
|
| | |
|
| | | public void setKey(String key) {
|
| | | this.key = key;
|
| | | }
|
| | |
|
| | | public String getValue() {
|
| | | return value;
|
| | | }
|
| | |
|
| | | public void setValue(String value) {
|
| | | this.value = value;
|
| | | }
|
| | |
|
| | | public String getRemark() {
|
| | | return remark;
|
| | | }
|
| | |
|
| | | public void setRemark(String remark) {
|
| | | this.remark = remark;
|
| | | }
|
| | |
|
| | | public Date getStartTime() {
|
| | | return startTime;
|
| | | }
|
| | |
|
| | | public void setStartTime(Date startTime) {
|
| | | this.startTime = startTime;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Date getUpdateTime() {
|
| | | return updateTime;
|
| | | }
|
| | |
|
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | } |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | |
|
| | | /**
|
| | | * 红包明细
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_red_pack_detail")
|
| | | public class RedPackDetail {
|
| | | public enum RedPackDetailTypeEnum {
|
| | | invite("立得现金", "http://img.flqapp.com/img/tlj/icon_tlj.png"), |
| | | newUserReward("新人奖励", "http://img.flqapp.com/img/tlj/icon_tlj.png"), |
| | | increaseReward("递增奖励", "http://img.flqapp.com/img/tlj/icon_tlj.png"), |
| | | seriesReward("连续奖励", "http://img.flqapp.com/img/tlj/icon_tlj.png"), |
| | | refund("红包退回", "http://img.flqapp.com/img/tlj/icon_tlj.png"), |
| | | videoRecharge("视频会员充值", "http://img.flqapp.com/img/tlj/icon_tlj.png"), |
| | | musicRecharge("音乐会员充值", "http://img.flqapp.com/img/tlj/icon_tlj.png"), |
| | | violation("红包涉嫌违规", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
|
| | | |
| | | giveOthers("红包赠送待领取中", "http://img.flqapp.com/img/tlj/icon_tlj.png"), |
| | | giveOthersSucceed("红包赠送领取成功", "http://img.flqapp.com/img/tlj/icon_tlj.png"), |
| | | giveOthersFail("红包赠送超时退回", "http://img.flqapp.com/img/tlj/icon_tlj.png"), |
| | | |
| | | redExchange("红包提现中", "http://img.flqapp.com/resource/money_detail/icon_score.png"),
|
| | | redExchangePass("红包提现成功", "http://img.flqapp.com/resource/money_detail/icon_score.png"),
|
| | | redExchangeReject("红包提现失败", "http://img.flqapp.com/resource/money_detail/icon_score.png");
|
| | |
|
| | | private final String desc;
|
| | | private final String picture;
|
| | |
|
| | | private RedPackDetailTypeEnum(String desc, String picture) {
|
| | | this.desc = desc;
|
| | | this.picture = picture;
|
| | | }
|
| | |
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | | |
| | | public String getPicture() {
|
| | | return picture;
|
| | | }
|
| | | }
|
| | |
|
| | | @Expose
|
| | | @Column(name = "rpd_id")
|
| | | private Long id;
|
| | | // 唯一标识
|
| | | @Column(name = "rpd_identify_code")
|
| | | private String identifyCode;
|
| | | @Expose
|
| | | @Column(name = "rpd_uid")
|
| | | private Long uid;
|
| | | @Expose
|
| | | @Column(name = "rpd_money")
|
| | | private BigDecimal money;
|
| | | @Expose
|
| | | @Column(name = "rpd_title")
|
| | | private String title;
|
| | | @Expose
|
| | | @Column(name = "rpd_type")
|
| | | private RedPackDetailTypeEnum type;
|
| | | @Expose
|
| | | @Column(name = "rpd_desc")
|
| | | private String desc;
|
| | | @Expose
|
| | | @Column(name = "rpd_remark")
|
| | | private String remark;
|
| | | @Expose
|
| | | @Column(name = "rpd_create_time")
|
| | | private Date createTime;
|
| | | // 是否显示
|
| | | @Column(name = "rpd_display")
|
| | | private Boolean display;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public BigDecimal getMoney() {
|
| | | return money;
|
| | | }
|
| | |
|
| | | public void setMoney(BigDecimal money) {
|
| | | this.money = money;
|
| | | }
|
| | |
|
| | | public String getTitle() {
|
| | | return title;
|
| | | }
|
| | |
|
| | | public void setTitle(String title) {
|
| | | this.title = title;
|
| | | }
|
| | |
|
| | | public RedPackDetailTypeEnum getType() {
|
| | | return type;
|
| | | }
|
| | |
|
| | | public void setType(RedPackDetailTypeEnum type) {
|
| | | this.type = type;
|
| | | }
|
| | |
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | |
|
| | | public void setDesc(String desc) {
|
| | | this.desc = desc;
|
| | | }
|
| | |
|
| | | public String getRemark() {
|
| | | return remark;
|
| | | }
|
| | |
|
| | | public void setRemark(String remark) {
|
| | | this.remark = remark;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public String getIdentifyCode() {
|
| | | return identifyCode;
|
| | | }
|
| | |
|
| | | public void setIdentifyCode(String identifyCode) {
|
| | | this.identifyCode = identifyCode;
|
| | | }
|
| | |
|
| | | public Boolean getDisplay() {
|
| | | return display;
|
| | | }
|
| | |
|
| | | public void setDisplay(Boolean display) {
|
| | | this.display = display;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 红包转换现金
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_red_pack_exchange")
|
| | | public class RedPackExchange {
|
| | | public static final int STATE_INIT = 0;
|
| | | public static final int STATE_SUCCESS = 1;
|
| | | public static final int STATE_REJECT = 2;
|
| | | |
| | | @Column(name = "rpe_id")
|
| | | private Long id;
|
| | | // 用户id
|
| | | @Column(name = "rpe_uid")
|
| | | private Long uid;
|
| | | // 金额
|
| | | @Column(name = "rpe_money")
|
| | | private BigDecimal money;
|
| | | // 状态:0初始 1成功 2拒绝
|
| | | @Column(name = "rpe_state")
|
| | | private Integer state;
|
| | | // 审核人id
|
| | | @Column(name = "rpe_audit_id")
|
| | | private Long auditId;
|
| | | // 审核原因
|
| | | @Column(name = "rpe_reason")
|
| | | private String reason;
|
| | | // 审核时间
|
| | | @Column(name = "rpe_audit_time")
|
| | | private Date auditTime;
|
| | | // 申请时间
|
| | | @Column(name = "rpe_create_time")
|
| | | private Date createTime;
|
| | |
|
| | | private String portrait;// 头像
|
| | | private String nickName;// 昵称
|
| | | private String auditName;// 审核人
|
| | | |
| | | |
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public BigDecimal getMoney() {
|
| | | return money;
|
| | | }
|
| | |
|
| | | public void setMoney(BigDecimal money) {
|
| | | this.money = money;
|
| | | }
|
| | |
|
| | | public Integer getState() {
|
| | | return state;
|
| | | }
|
| | |
|
| | | public void setState(Integer state) {
|
| | | this.state = state;
|
| | | }
|
| | |
|
| | | public Long getAuditId() {
|
| | | return auditId;
|
| | | }
|
| | |
|
| | | public void setAuditId(Long auditId) {
|
| | | this.auditId = auditId;
|
| | | }
|
| | | |
| | | public String getReason() {
|
| | | return reason;
|
| | | }
|
| | |
|
| | | public void setReason(String reason) {
|
| | | this.reason = reason;
|
| | | }
|
| | |
|
| | | public Date getAuditTime() {
|
| | | return auditTime;
|
| | | }
|
| | |
|
| | | public void setAuditTime(Date auditTime) {
|
| | | this.auditTime = auditTime;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public String getPortrait() {
|
| | | return portrait;
|
| | | }
|
| | |
|
| | | public void setPortrait(String portrait) {
|
| | | this.portrait = portrait;
|
| | | }
|
| | |
|
| | | public String getNickName() {
|
| | | return nickName;
|
| | | }
|
| | |
|
| | | public void setNickName(String nickName) {
|
| | | this.nickName = nickName;
|
| | | }
|
| | |
|
| | | public String getAuditName() {
|
| | | return auditName;
|
| | | }
|
| | |
|
| | | public void setAuditName(String auditName) {
|
| | | this.auditName = auditName;
|
| | | }
|
| | | |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 红包赠送记录
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_red_pack_give_record")
|
| | | public class RedPackGiveRecord {
|
| | |
|
| | | // 未领取
|
| | | public final static int STATE_INIT = 0;
|
| | | // 已领取
|
| | | public final static int STATE_RECEIVE = 1;
|
| | | // 已过期 退回
|
| | | public final static int STATE_OVERDUE = 2;
|
| | |
|
| | | @Column(name = "rpgr_id")
|
| | | private Long id;
|
| | | // 面额
|
| | | @Column(name = "rpgr_money")
|
| | | private BigDecimal amount;
|
| | | // 赠送uid
|
| | | @Column(name = "rpgr_give_uid")
|
| | | private Long giveUid;
|
| | | // 赠送时间
|
| | | @Column(name = "rpgr_give_time")
|
| | | private Date giveTime;
|
| | | // 赠送结束时间
|
| | | @Column(name = "rpgr_end_time")
|
| | | private Date endTime;
|
| | | // 领取uid
|
| | | @Column(name = "rpgr_receive_uid")
|
| | | private Long receiveUid;
|
| | | // 领取时间
|
| | | @Column(name = "rpgr_receive_time")
|
| | | private Date receiveTime;
|
| | | // 状态:0初始 1已领取 2已退回
|
| | | @Column(name = "rpgr_state")
|
| | | private Integer state;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public BigDecimal getAmount() {
|
| | | return amount;
|
| | | }
|
| | |
|
| | | public void setAmount(BigDecimal amount) {
|
| | | this.amount = amount;
|
| | | }
|
| | |
|
| | | public Long getGiveUid() {
|
| | | return giveUid;
|
| | | }
|
| | |
|
| | | public void setGiveUid(Long giveUid) {
|
| | | this.giveUid = giveUid;
|
| | | }
|
| | |
|
| | | public Date getGiveTime() {
|
| | | return giveTime;
|
| | | }
|
| | |
|
| | | public void setGiveTime(Date giveTime) {
|
| | | this.giveTime = giveTime;
|
| | | }
|
| | |
|
| | | public Date getEndTime() {
|
| | | return endTime;
|
| | | }
|
| | |
|
| | | public void setEndTime(Date endTime) {
|
| | | this.endTime = endTime;
|
| | | }
|
| | |
|
| | | public Long getReceiveUid() {
|
| | | return receiveUid;
|
| | | }
|
| | |
|
| | | public void setReceiveUid(Long receiveUid) {
|
| | | this.receiveUid = receiveUid;
|
| | | }
|
| | |
|
| | | public Date getReceiveTime() {
|
| | | return receiveTime;
|
| | | }
|
| | |
|
| | | public void setReceiveTime(Date receiveTime) {
|
| | | this.receiveTime = receiveTime;
|
| | | }
|
| | |
|
| | | public Integer getState() {
|
| | | return state;
|
| | | }
|
| | |
|
| | | public void setState(Integer state) {
|
| | | this.state = state;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.redpack;
|
| | |
|
| | | import com.yeshi.fanli.exception.BaseException;
|
| | |
|
| | | /**
|
| | | * 红包异常
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class RedPackBalanceException extends BaseException {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public RedPackBalanceException(int code, String msg) {
|
| | | super(code, msg);
|
| | | }
|
| | |
|
| | | public RedPackBalanceException() {
|
| | | super();
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.redpack;
|
| | |
|
| | | import com.yeshi.fanli.exception.BaseException;
|
| | |
|
| | | /**
|
| | | * 红包明细异常
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class RedPackDetailException extends BaseException {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public RedPackDetailException(int code, String msg) {
|
| | | super(code, msg);
|
| | | }
|
| | |
|
| | | public RedPackDetailException() {
|
| | | super();
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.redpack;
|
| | |
|
| | | import com.yeshi.fanli.exception.BaseException;
|
| | |
|
| | | /**
|
| | | * 红包提现异常
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class RedPackExchangeException extends BaseException {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public RedPackExchangeException(int code, String msg) {
|
| | | super(code, msg);
|
| | | }
|
| | |
|
| | | public RedPackExchangeException() {
|
| | | super();
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.redpack;
|
| | |
|
| | | import com.yeshi.fanli.exception.BaseException;
|
| | |
|
| | | /**
|
| | | * 红包赠送异常
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class RedPackGiveRecordException extends BaseException {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public RedPackGiveRecordException(int code, String msg) {
|
| | | super(code, msg);
|
| | | }
|
| | |
|
| | | public RedPackGiveRecordException() {
|
| | | super();
|
| | | }
|
| | | }
|
New file |
| | |
| | | <?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"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.redpack.RedPackBalanceMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackBalance"> |
| | | <id column="rpb_uid" property="id" jdbcType="BIGINT"/> |
| | | <result column="rpb_money" property="money" jdbcType="DECIMAL"/> |
| | | <result column="rpb_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="rpb_update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">rpb_uid,rpb_money,rpb_create_time,rpb_update_time</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_red_pack_balance where rpb_uid = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_balance where rpb_uid = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_balance (rpb_uid,rpb_money,rpb_create_time,rpb_update_time) values (#{id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_balance |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">rpb_uid,</if> |
| | | <if test="money != null">rpb_money,</if> |
| | | <if test="createTime != null">rpb_create_time,</if> |
| | | <if test="updateTime != null">rpb_update_time,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="money != null">#{money,jdbcType=DECIMAL},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance">update yeshi_red_pack_balance set rpb_money = #{money,jdbcType=DECIMAL},rpb_create_time = #{createTime,jdbcType=TIMESTAMP},rpb_update_time = #{updateTime,jdbcType=TIMESTAMP} where rpb_uid = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance">update yeshi_red_pack_balance |
| | | <set> |
| | | <if test="money != null">rpb_money=#{money,jdbcType=DECIMAL},</if> |
| | | <if test="createTime != null">rpb_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">rpb_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> where rpb_uid = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <update id="subRedPack"> |
| | | update yeshi_red_pack_balance SET rpb_money = rpb_money - #{money,jdbcType=DECIMAL},rpb_update_time = NOW() |
| | | WHERE rpb_uid = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <update id="addRedPack"> |
| | | UPDATE yeshi_red_pack_balance SET rpb_money = rpb_money + #{money,jdbcType=DECIMAL},rpb_update_time = NOW() |
| | | WHERE rpb_uid = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <select id="selectForUpdate" resultMap="BaseResultMap" parameterType="java.lang.Long"> |
| | | SELECT <include refid="Base_Column_List"/> FROM yeshi_red_pack_balance |
| | | WHERE rpb_uid = #{id,jdbcType=BIGINT} FOR UPDATE |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?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"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.redpack.RedPackConfigMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackConfig"> |
| | | <id column="rpc_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="rpc_name" property="name" jdbcType="VARCHAR"/> |
| | | <result column="rpc_key" property="key" jdbcType="VARCHAR"/> |
| | | <result column="rpc_value" property="value" jdbcType="VARCHAR"/> |
| | | <result column="rpc_remark" property="remark" jdbcType="VARCHAR"/> |
| | | <result column="rpc_start_time" property="startTime" jdbcType="TIMESTAMP"/> |
| | | <result column="rpc_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="rpc_update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">rpc_id,rpc_name,rpc_key,rpc_value,rpc_remark,rpc_start_time,rpc_create_time,rpc_update_time</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_red_pack_config where rpc_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_config where rpc_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_config (rpc_id,rpc_name,rpc_key,rpc_value,rpc_remark,rpc_start_time,rpc_create_time,rpc_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{key,jdbcType=VARCHAR},#{value,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{startTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_config |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">rpc_id,</if> |
| | | <if test="name != null">rpc_name,</if> |
| | | <if test="key != null">rpc_key,</if> |
| | | <if test="value != null">rpc_value,</if> |
| | | <if test="remark != null">rpc_remark,</if> |
| | | <if test="startTime != null">rpc_start_time,</if> |
| | | <if test="createTime != null">rpc_create_time,</if> |
| | | <if test="updateTime != null">rpc_update_time,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="name != null">#{name,jdbcType=VARCHAR},</if> |
| | | <if test="key != null">#{key,jdbcType=VARCHAR},</if> |
| | | <if test="value != null">#{value,jdbcType=VARCHAR},</if> |
| | | <if test="remark != null">#{remark,jdbcType=VARCHAR},</if> |
| | | <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig">update yeshi_red_pack_config set rpc_name = #{name,jdbcType=VARCHAR},rpc_key = #{key,jdbcType=VARCHAR},rpc_value = #{value,jdbcType=VARCHAR},rpc_remark = #{remark,jdbcType=VARCHAR},rpc_start_time = #{startTime,jdbcType=TIMESTAMP},rpc_create_time = #{createTime,jdbcType=TIMESTAMP},rpc_update_time = #{updateTime,jdbcType=TIMESTAMP} where rpc_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig">update yeshi_red_pack_config |
| | | <set> |
| | | <if test="name != null">rpc_name=#{name,jdbcType=VARCHAR},</if> |
| | | <if test="key != null">rpc_key=#{key,jdbcType=VARCHAR},</if> |
| | | <if test="value != null">rpc_value=#{value,jdbcType=VARCHAR},</if> |
| | | <if test="remark != null">rpc_remark=#{remark,jdbcType=VARCHAR},</if> |
| | | <if test="startTime != null">rpc_start_time=#{startTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createTime != null">rpc_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">rpc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> where rpc_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <select id="getByKey" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_red_pack_config t |
| | | WHERE t.`rpc_key` = #{key} and #{startTime} >= rpc_start_time |
| | | ORDER BY rpc_start_time DESC LIMIT 1 |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?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"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.redpack.RedPackDetailMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackDetail"> |
| | | <id column="rpd_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="rpd_identify_code" property="identifyCode" jdbcType="VARCHAR"/> |
| | | <result column="rpd_uid" property="uid" jdbcType="BIGINT"/> |
| | | <result column="rpd_money" property="money" jdbcType="DECIMAL"/> |
| | | <result column="rpd_title" property="title" jdbcType="VARCHAR"/> |
| | | <result column="rpd_desc" property="desc" jdbcType="VARCHAR"/> |
| | | <result column="rpd_remark" property="remark" jdbcType="VARCHAR"/> |
| | | <result column="rpd_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="rpd_display" property="display" jdbcType="VARCHAR"/> |
| | | <result column="rpd_type" property="type" typeHandler="com.yeshi.fanli.util.mybatishandler.redpack.RedPackDetailTypeEnumHandler"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="UserMonthMoneyMap" type="com.yeshi.fanli.vo.redpack.RedPackMonthVO"> |
| | | <result column="expend" property="expend" jdbcType="DECIMAL" /> |
| | | <result column="income" property="income" jdbcType="DECIMAL" /> |
| | | <result column="dateFormate" property="dateFormate" jdbcType="VARCHAR" /> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List">rpd_id,rpd_identify_code,rpd_uid,rpd_money,rpd_title,rpd_type,rpd_desc,rpd_remark,rpd_create_time,rpd_display</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_red_pack_detail where rpd_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_detail where rpd_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_detail (rpd_id,rpd_identify_code,rpd_uid,rpd_money,rpd_title,rpd_type,rpd_desc,rpd_remark,rpd_create_time,rpd_display) values (#{id,jdbcType=BIGINT},,#{identifyCode,jdbcType=VARCHAR}#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{title,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{desc,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{display,jdbcType=VARCHAR})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_detail |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">rpd_id,</if> |
| | | <if test="identifyCode != null">rpd_identify_code,</if> |
| | | <if test="uid != null">rpd_uid,</if> |
| | | <if test="money != null">rpd_money,</if> |
| | | <if test="title != null">rpd_title,</if> |
| | | <if test="type != null">rpd_type,</if> |
| | | <if test="desc != null">rpd_desc,</if> |
| | | <if test="remark != null">rpd_remark,</if> |
| | | <if test="createTime != null">rpd_create_time,</if> |
| | | <if test="display != null">rpd_display,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="identifyCode != null">#{identifyCode,jdbcType=VARCHAR},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="money != null">#{money,jdbcType=DECIMAL},</if> |
| | | <if test="title != null">#{title,jdbcType=VARCHAR},</if> |
| | | <if test="type != null">#{type,jdbcType=VARCHAR},</if> |
| | | <if test="desc != null">#{desc,jdbcType=VARCHAR},</if> |
| | | <if test="remark != null">#{remark,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="display != null">#{display,jdbcType=VARCHAR},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail">update yeshi_red_pack_detail set rpd_identify_code = #{identifyCode,jdbcType=VARCHAR},rpd_uid = #{uid,jdbcType=BIGINT},rpd_money = #{money,jdbcType=DECIMAL},rpd_title = #{title,jdbcType=VARCHAR},rpd_type = #{type,jdbcType=VARCHAR},rpd_desc = #{desc,jdbcType=VARCHAR},rpd_remark = #{remark,jdbcType=VARCHAR},rpd_create_time = #{createTime,jdbcType=TIMESTAMP} where rpd_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail">update yeshi_red_pack_detail |
| | | <set> |
| | | <if test="identifyCode != null">rpd_identify_code=#{identifyCode,jdbcType=VARCHAR},</if> |
| | | <if test="uid != null">rpd_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="money != null">rpd_money=#{money,jdbcType=DECIMAL},</if> |
| | | <if test="title != null">rpd_title=#{title,jdbcType=VARCHAR},</if> |
| | | <if test="type != null">rpd_type=#{type,jdbcType=VARCHAR},</if> |
| | | <if test="desc != null">rpd_desc=#{desc,jdbcType=VARCHAR},</if> |
| | | <if test="remark != null">rpd_remark=#{remark,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">rpd_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="display != null">rpd_display=#{display,jdbcType=VARCHAR},</if> |
| | | </set> where rpd_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | |
| | | <select id="countUseMoneyByDate" resultType="java.math.BigDecimal"> |
| | | SELECT IFNULL(SUM(t.`rpd_money`),0) FROM `yeshi_red_pack_detail` t |
| | | WHERE t.`rpd_money` <![CDATA[<]]> 0 AND t.`rpd_uid` = #{uid} AND t.`rpd_type` <![CDATA[<>]]> 'violation' |
| | | <if test="dateType == 1"> <!-- 今日 --> |
| | | AND TO_DAYS(t.`rpd_create_time`) = TO_DAYS(NOW()); |
| | | </if> |
| | | <if test="dateType == 2"> <!-- 昨日 --> |
| | | AND TO_DAYS(NOW()) - TO_DAYS(t.`rpd_create_time`) = 1 |
| | | </if> |
| | | <if test="dateType == 3"> <!-- 本月 --> |
| | | AND DATE_FORMAT(t.`rpd_create_time`, '%Y%m') =DATE_FORMAT(CURDATE(), '%Y%m') |
| | | </if> |
| | | <if test="dateType == 4"> <!--上月 --> |
| | | AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),DATE_FORMAT(t.`rpd_create_time`, '%Y%m')) = 1 |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <select id="countAddMoneyByDate" resultType="java.math.BigDecimal"> |
| | | SELECT IFNULL(SUM(t.`rpd_money`),0) FROM `yeshi_red_pack_detail` t |
| | | WHERE t.`rpd_money` <![CDATA[>]]> 0 AND t.`rpd_uid` = #{uid} AND t.`rpd_type`<![CDATA[<>]]>'refund' |
| | | <if test="dateType == 1"> <!-- 今日 --> |
| | | AND TO_DAYS(t.`rpd_create_time`) = TO_DAYS(NOW()); |
| | | </if> |
| | | <if test="dateType == 2"> <!-- 昨日 --> |
| | | AND TO_DAYS(NOW()) - TO_DAYS(t.`rpd_create_time`) = 1 |
| | | </if> |
| | | <if test="dateType == 3"> <!-- 本月 --> |
| | | AND DATE_FORMAT(t.`rpd_create_time`, '%Y%m') =DATE_FORMAT(CURDATE(), '%Y%m') |
| | | </if> |
| | | <if test="dateType == 4"> <!--上月 --> |
| | | AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),DATE_FORMAT(t.`rpd_create_time`, '%Y%m')) = 1 |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="selectByMaxCreateTime" resultMap="BaseResultMap"> |
| | | SELECT <include refid="Base_Column_List" /> FROM yeshi_red_pack_detail t |
| | | WHERE t.`rpd_uid`=#{uid} AND t.`rpd_create_time`<![CDATA[<=]]> #{date} |
| | | ORDER BY t.`rpd_create_time` DESC,t.rpd_id DESC |
| | | LIMIT #{count} |
| | | </select> |
| | | |
| | | <select id="selectByUidWithIndexId" resultMap="BaseResultMap"> |
| | | SELECT <include refid="Base_Column_List" /> FROM yeshi_red_pack_detail t |
| | | WHERE t.`rpd_uid`=#{uid} |
| | | AND t.`rpd_create_time`<![CDATA[<=]]>(SELECT rpd_create_time FROM yeshi_red_pack_detail WHERE rpd_id =#{id}) |
| | | ORDER BY t.`rpd_create_time` DESC,t.rpd_id DESC |
| | | LIMIT #{count} |
| | | </select> |
| | | |
| | | <select id="selectMonthMoneyByUid" resultMap="UserMonthMoneyMap"> |
| | | <foreach collection="dateFormat" index="index" item="item" |
| | | separator="UNION ALL"> |
| | | <trim prefix="(" suffix=")"> |
| | | SELECT c.time AS dateFormate , IF(a.money IS NULL,0,a.money) AS income ,IF(b.money IS NULL,0,b.money) AS expend |
| | | FROM (SELECT #{item} AS `time`) c |
| | | LEFT JOIN (SELECT DATE_FORMAT(d.`rpd_create_time`,'%Y-%m') AS `time`,SUM(d.`rpd_money`)AS money |
| | | FROM `yeshi_red_pack_detail` d |
| | | WHERE d.`rpd_uid`=#{uid} AND d.`rpd_money`<![CDATA[>=]]>0 AND DATE_FORMAT(d.`rpd_create_time`,'%Y-%m')=#{item} |
| | | GROUP BY DATE_FORMAT(d.`rpd_create_time`,'%Y-%m') |
| | | ) a ON a.time=c.time |
| | | |
| | | LEFT JOIN(SELECT DATE_FORMAT(d.`rpd_create_time`,'%Y-%m') AS `time`,SUM(d.`rpd_money`) AS money |
| | | FROM `yeshi_red_pack_detail` d |
| | | WHERE d.`rpd_uid`=#{uid} AND d.`rpd_money` <![CDATA[<]]>0 AND DATE_FORMAT(d.`rpd_create_time`,'%Y-%m')=#{item} |
| | | GROUP BY DATE_FORMAT(d.`rpd_create_time`,'%Y-%m') |
| | | ) b ON c.time=b.time |
| | | </trim> |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="selectCountByUid" resultType="java.lang.Long" parameterType="java.lang.Long"> |
| | | SELECT count(rpd_id) FROM yeshi_red_pack_detail |
| | | WHERE rpd_uid=#{uid} |
| | | </select> |
| | | |
| | | <select id="selectMonthCountByUid" resultType="java.lang.Integer"> |
| | | SELECT COUNT(*) FROM |
| | | (SELECT * FROM yeshi_red_pack_detail d |
| | | WHERE d.`rpd_uid`=#{uid} AND d.`rpd_create_time` <![CDATA[<=]]> #{date} |
| | | GROUP BY DATE_FORMAT(d.`rpd_create_time`,'%y-%m') |
| | | ) a |
| | | </select> |
| | | |
| | | <select id="selectCountByUidAndMaxCreateTime" resultType="java.lang.Long"> |
| | | SELECT count(rpd_id) FROM yeshi_red_pack_detail |
| | | WHERE rpd_uid=#{uid} and `rpd_create_time`<![CDATA[<=]]>#{date} |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?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"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.redpack.RedPackExchangeMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackExchange"> |
| | | <id column="rpe_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="rpe_uid" property="uid" jdbcType="BIGINT"/> |
| | | <result column="rpe_money" property="money" jdbcType="DECIMAL"/> |
| | | <result column="rpe_state" property="state" jdbcType="INTEGER"/> |
| | | <result column="rpe_audit_id" property="auditId" jdbcType="BIGINT"/> |
| | | <result column="rpe_reason" property="reason" jdbcType="VARCHAR"/> |
| | | <result column="rpe_audit_time" property="auditTime" jdbcType="TIMESTAMP"/> |
| | | <result column="rpe_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">rpe_id,rpe_uid,rpe_money,rpe_state,rpe_audit_id,rpe_reason,rpe_audit_time,rpe_create_time</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_red_pack_exchange where rpe_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_exchange where rpe_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_exchange (rpe_id,rpe_uid,rpe_money,rpe_state,rpe_audit_id,rpe_reason,rpe_audit_time,rpe_create_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{state,jdbcType=INTEGER},#{auditId,jdbcType=BIGINT},#{reason,jdbcType=VARCHAR},#{auditTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_exchange |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">rpe_id,</if> |
| | | <if test="uid != null">rpe_uid,</if> |
| | | <if test="money != null">rpe_money,</if> |
| | | <if test="state != null">rpe_state,</if> |
| | | <if test="auditId != null">rpe_audit_id,</if> |
| | | <if test="reason != null">rpe_reason,</if> |
| | | <if test="auditTime != null">rpe_audit_time,</if> |
| | | <if test="createTime != null">rpe_create_time,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="money != null">#{money,jdbcType=DECIMAL},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | <if test="auditId != null">#{auditId,jdbcType=BIGINT},</if> |
| | | <if test="reason != null">#{reason,jdbcType=VARCHAR},</if> |
| | | <if test="auditTime != null">#{auditTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange">update yeshi_red_pack_exchange set rpe_uid = #{uid,jdbcType=BIGINT},rpe_money = #{money,jdbcType=DECIMAL},rpe_state = #{state,jdbcType=INTEGER},rpe_audit_id = #{auditId,jdbcType=BIGINT},rpe_reason = #{reason,jdbcType=VARCHAR},rpe_audit_time = #{auditTime,jdbcType=TIMESTAMP},rpe_create_time = #{createTime,jdbcType=TIMESTAMP} where rpe_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange">update yeshi_red_pack_exchange |
| | | <set> |
| | | <if test="uid != null">rpe_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="money != null">rpe_money=#{money,jdbcType=DECIMAL},</if> |
| | | <if test="state != null">rpe_state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="auditId != null">rpe_audit_id=#{auditId,jdbcType=BIGINT},</if> |
| | | <if test="reason != null">rpe_reason=#{reason,jdbcType=VARCHAR},</if> |
| | | <if test="auditTime != null">rpe_audit_time=#{auditTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createTime != null">rpe_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | </set> where rpe_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <select id="query" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_red_pack_exchange d |
| | | WHERE 1=1 |
| | | <if test="key != null and key != ''"> |
| | | AND d.rpe_uid = #{key} |
| | | </if> |
| | | <if test="state != null "> |
| | | AND d.rpe_state = #{state} |
| | | </if> |
| | | ORDER BY d.`rpe_state`,d.`rpe_create_time` |
| | | LIMIT #{start},#{count} |
| | | </select> |
| | | |
| | | <select id="count" resultType="Long"> |
| | | SELECT IFNULL(COUNT(rpe_id),0) FROM yeshi_red_pack_exchange d |
| | | WHERE 1=1 |
| | | <if test="key != null and key != ''"> |
| | | AND d.rpe_uid = #{key} |
| | | </if> |
| | | <if test="state != null "> |
| | | AND d.rpe_state = #{state} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="countState" resultType="Long"> |
| | | SELECT IFNULL(COUNT(d.rpe_id),0) FROM yeshi_red_pack_exchange d |
| | | WHERE d.rpe_uid = #{uid} |
| | | GROUP BY d.`rpe_state` |
| | | ORDER BY d.`rpe_state` |
| | | </select> |
| | | |
| | | <select id="countMoneyState" resultType="BigDecimal"> |
| | | SELECT IFNULL(SUM(d.rpe_money),0) FROM yeshi_red_pack_exchange d |
| | | WHERE d.rpe_uid = #{uid} |
| | | GROUP BY d.`rpe_state` |
| | | ORDER BY d.`rpe_state` |
| | | </select> |
| | | |
| | | <select id="countMoneyByState" resultType="BigDecimal"> |
| | | SELECT IFNULL(SUM(d.rpe_money),0) FROM yeshi_red_pack_exchange d |
| | | WHERE d.rpe_uid = #{uid} AND d.`rpe_state` = #{state} |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?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"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.redpack.RedPackGiveRecordMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackGiveRecord"> |
| | | <id column="rpgr_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="rpgr_money" property="amount" jdbcType="DECIMAL"/> |
| | | <result column="rpgr_give_uid" property="giveUid" jdbcType="BIGINT"/> |
| | | <result column="rpgr_give_time" property="giveTime" jdbcType="TIMESTAMP"/> |
| | | <result column="rpgr_end_time" property="endTime" jdbcType="TIMESTAMP"/> |
| | | <result column="rpgr_receive_uid" property="receiveUid" jdbcType="BIGINT"/> |
| | | <result column="rpgr_receive_time" property="receiveTime" jdbcType="TIMESTAMP"/> |
| | | <result column="rpgr_state" property="state" jdbcType="INTEGER"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">rpgr_id,rpgr_money,rpgr_give_uid,rpgr_give_time,rpgr_end_time,rpgr_receive_uid,rpgr_receive_time,rpgr_state</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_red_pack_give_record where rpgr_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_give_record where rpgr_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_give_record (rpgr_id,rpgr_money,rpgr_give_uid,rpgr_give_time,rpgr_end_time,rpgr_receive_uid,rpgr_receive_time,rpgr_state) values (#{id,jdbcType=BIGINT},#{amount,jdbcType=DECIMAL},#{giveUid,jdbcType=BIGINT},#{giveTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{receiveUid,jdbcType=BIGINT},#{receiveTime,jdbcType=TIMESTAMP},#{state,jdbcType=INTEGER})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_give_record |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">rpgr_id,</if> |
| | | <if test="amount != null">rpgr_money,</if> |
| | | <if test="giveUid != null">rpgr_give_uid,</if> |
| | | <if test="giveTime != null">rpgr_give_time,</if> |
| | | <if test="endTime != null">rpgr_end_time,</if> |
| | | <if test="receiveUid != null">rpgr_receive_uid,</if> |
| | | <if test="receiveTime != null">rpgr_receive_time,</if> |
| | | <if test="state != null">rpgr_state,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="amount != null">#{amount,jdbcType=DECIMAL},</if> |
| | | <if test="giveUid != null">#{giveUid,jdbcType=BIGINT},</if> |
| | | <if test="giveTime != null">#{giveTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="receiveUid != null">#{receiveUid,jdbcType=BIGINT},</if> |
| | | <if test="receiveTime != null">#{receiveTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord">update yeshi_red_pack_give_record set rpgr_money = #{amount,jdbcType=DECIMAL},rpgr_give_uid = #{giveUid,jdbcType=BIGINT},rpgr_give_time = #{giveTime,jdbcType=TIMESTAMP},rpgr_end_time = #{endTime,jdbcType=TIMESTAMP},rpgr_receive_uid = #{receiveUid,jdbcType=BIGINT},rpgr_receive_time = #{receiveTime,jdbcType=TIMESTAMP},rpgr_state = #{state,jdbcType=INTEGER} where rpgr_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord">update yeshi_red_pack_give_record |
| | | <set> |
| | | <if test="amount != null">rpgr_money=#{amount,jdbcType=DECIMAL},</if> |
| | | <if test="giveUid != null">rpgr_give_uid=#{giveUid,jdbcType=BIGINT},</if> |
| | | <if test="giveTime != null">rpgr_give_time=#{giveTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="endTime != null">rpgr_end_time=#{endTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="receiveUid != null">rpgr_receive_uid=#{receiveUid,jdbcType=BIGINT},</if> |
| | | <if test="receiveTime != null">rpgr_receive_time=#{receiveTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="state != null">rpgr_state=#{state,jdbcType=INTEGER},</if> |
| | | </set> where rpgr_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
New file |
| | |
| | | package com.yeshi.fanli.service.impl.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.redpack.RedPackBalanceMapper;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackBalance;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
|
| | |
|
| | | @Service
|
| | | public class RedPackBalanceServiceImpl implements RedPackBalanceService {
|
| | |
|
| | | @Resource
|
| | | private RedPackBalanceMapper redPackBalanceMapper;
|
| | | |
| | | @Resource
|
| | | private RedPackDetailService redPackDetailService;
|
| | |
|
| | | @Override
|
| | | public RedPackBalance selectByPrimaryKey(Long uid) {
|
| | | return redPackBalanceMapper.selectByPrimaryKey(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getBalance(Long uid) {
|
| | | if (uid == null || uid == 0)
|
| | | return null;
|
| | | |
| | | RedPackBalance redPackBalance = redPackBalanceMapper.selectByPrimaryKey(uid);
|
| | | if (redPackBalance != null)
|
| | | return redPackBalance.getMoney();
|
| | | |
| | | return null;
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void addRedPack(Long uid, BigDecimal money) {
|
| | | if (uid == null || uid == 0 || money == null)
|
| | | return;
|
| | | RedPackBalance redPackBalance = redPackBalanceMapper.selectForUpdate(uid);
|
| | | if (redPackBalance == null) {
|
| | | redPackBalance = new RedPackBalance();
|
| | | redPackBalance.setId(uid);
|
| | | redPackBalance.setMoney(money);
|
| | | redPackBalance.setCreateTime(new Date());
|
| | | redPackBalance.setUpdateTime(new Date());
|
| | | redPackBalanceMapper.insertSelective(redPackBalance);
|
| | | } else {
|
| | | redPackBalanceMapper.addRedPack(uid, money);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void addRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException {
|
| | | if (uid == null || uid == 0 || money == null || detail == null)
|
| | | throw new RedPackBalanceException(1, "参数传递不完整");
|
| | | // 加入明细
|
| | | redPackDetailService.insertSelective(detail);
|
| | | // 减少红包
|
| | | redPackBalanceMapper.addRedPack(uid, money);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void subRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException {
|
| | | if (uid == null || uid == 0 || money == null || detail == null)
|
| | | throw new RedPackBalanceException(1, "参数传递不完整");
|
| | | // 加入明细
|
| | | redPackDetailService.insertSelective(detail);
|
| | | // 减少红包
|
| | | redPackBalanceMapper.subRedPack(uid, money);
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.redpack;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.redpack.RedPackConfigMapper;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackConfig;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
|
| | |
|
| | | @Service
|
| | | public class RedPackConfigServiceImpl implements RedPackConfigService {
|
| | |
|
| | | @Resource
|
| | | private RedPackConfigMapper redPackConfigMapper;
|
| | |
|
| | | @Override
|
| | | public RedPackConfig getByKey(String key) {
|
| | | return redPackConfigMapper.getByKey(key, new Date());
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "redpackCache", key = "'getValueByKey-' + #key")
|
| | | public String getValueByKey(String key) {
|
| | | RedPackConfig config = redPackConfigMapper.getByKey(key, new Date());
|
| | | if (config != null) {
|
| | | return config.getValue();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public RedPackConfig getByKey(String key, Date date) {
|
| | | if (date == null)
|
| | | return getByKey(key);
|
| | | return redPackConfigMapper.getByKey(key, date);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String getValueByKey(String key, Date date) {
|
| | | if (date == null)
|
| | | return getValueByKey(key);
|
| | | RedPackConfig config = redPackConfigMapper.getByKey(key, date);
|
| | | if (config != null) {
|
| | | return config.getValue();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.HashSet;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | | import java.util.TreeMap;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.redpack.RedPackDetailMapper;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.vo.redpack.RedPackDetailVO;
|
| | | import com.yeshi.fanli.vo.redpack.RedPackMonthVO;
|
| | |
|
| | | @Service
|
| | | public class RedPackDetailServiceImpl implements RedPackDetailService {
|
| | |
|
| | | @Resource
|
| | | private RedPackDetailMapper redPackDetailMapper;
|
| | |
|
| | | @Override
|
| | | public void insertSelective(RedPackDetail record) {
|
| | | redPackDetailMapper.insertSelective(record);
|
| | | }
|
| | | |
| | | @Override
|
| | | public void updateByPrimaryKeySelective(RedPackDetail record) {
|
| | | redPackDetailMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | | |
| | | @Override
|
| | | public RedPackDetail getByIdentifyCode(String identifyCode) {
|
| | | return redPackDetailMapper.getByIdentifyCode(identifyCode);
|
| | | }
|
| | | |
| | | @Override
|
| | | public BigDecimal countAddMoneyByDate(long uid, int dateType) {
|
| | | return redPackDetailMapper.countAddMoneyByDate(uid, dateType);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public BigDecimal countUseMoneyByDate(long uid, int dateType) {
|
| | | return redPackDetailMapper.countUseMoneyByDate(uid, dateType);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<RedPackDetailVO> listUserMoneyDetailForClient(Long uid, Long detailId, Date maxTime) {
|
| | | List<RedPackDetailVO> finalList = new ArrayList<>();
|
| | | List<RedPackDetail> list = null;
|
| | | if (detailId == null) {// 首次请求
|
| | | if (maxTime == null)// 没有筛选时间
|
| | | {
|
| | | list = redPackDetailMapper.selectByMaxCreateTime(uid,
|
| | | new Date(System.currentTimeMillis() + 1000 * 60 * 60L), 20);
|
| | | } else {// 筛选了时间
|
| | | list = redPackDetailMapper.selectByMaxCreateTime(uid, maxTime, 20);
|
| | | }
|
| | | if (list != null && list.size() > 0) {
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTimeInMillis(list.get(0).getCreateTime().getTime());
|
| | | RedPackDetailVO vo = new RedPackDetailVO();
|
| | | vo.setMonth(new RedPackMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1));
|
| | | finalList.add(vo);
|
| | | } else {
|
| | | if (maxTime != null) {//
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTimeInMillis(maxTime.getTime());
|
| | | RedPackDetailVO vo = new RedPackDetailVO();
|
| | | vo.setMonth(new RedPackMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1));
|
| | | vo.getMonth().setExpend("0");
|
| | | vo.getMonth().setIncome("0");
|
| | | finalList.add(vo);
|
| | | }
|
| | | }
|
| | |
|
| | | } else {// 二次请求
|
| | |
|
| | | int size = 21;
|
| | | List<RedPackDetail> tempList = redPackDetailMapper.selectByUidWithIndexId(uid, detailId, size);
|
| | | Set<Date> dateSet = new HashSet<>();// 用于储存是否在同一时间上面(精确到秒)
|
| | | if (tempList.size() > 0) {
|
| | | for (RedPackDetail umd : tempList) {
|
| | | dateSet.add(umd.getCreateTime());
|
| | | }
|
| | |
|
| | | List<RedPackDetail> tempList2 = new ArrayList<>();
|
| | | while (dateSet.size() == 1 && tempList2.size() != tempList.size() && size < 40) {// 只有一个时间点的数据
|
| | | tempList = tempList2;
|
| | | size += 10;
|
| | | tempList2 = redPackDetailMapper.selectByUidWithIndexId(uid, detailId, size);
|
| | | dateSet.clear();
|
| | | for (RedPackDetail umd : tempList2) {
|
| | | dateSet.add(umd.getCreateTime());
|
| | | }
|
| | | }
|
| | | if (tempList2.size() > 0)
|
| | | tempList = tempList2;
|
| | | }
|
| | |
|
| | | for (int i = 0; i < tempList.size(); i++) {
|
| | | if (tempList.get(i).getId().longValue() == detailId) {
|
| | | tempList.remove(i);
|
| | | break;
|
| | | } else {
|
| | | tempList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | list = tempList;
|
| | | }
|
| | |
|
| | | if (list != null) {
|
| | | if (detailId != null && list.size() > 0) {
|
| | | RedPackDetail umd = redPackDetailMapper.selectByPrimaryKey(detailId);
|
| | | if (!TimeUtil.getGernalTime(umd.getCreateTime().getTime(), "yyyy-MM")
|
| | | .equalsIgnoreCase(TimeUtil.getGernalTime(list.get(0).getCreateTime().getTime(), "yyyy-MM"))) {
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTimeInMillis(list.get(0).getCreateTime().getTime());
|
| | | RedPackDetailVO vo = new RedPackDetailVO();
|
| | | vo.setMonth(new RedPackMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1));
|
| | | finalList.add(vo);
|
| | | }
|
| | |
|
| | | }
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (i > 0 && !TimeUtil.getGernalTime(list.get(i - 1).getCreateTime().getTime(), "yyyy-MM")
|
| | | .equalsIgnoreCase(TimeUtil.getGernalTime(list.get(i).getCreateTime().getTime(), "yyyy-MM"))) {// 本条数据与上条数据不是同一月则插入月份
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTimeInMillis(list.get(i).getCreateTime().getTime());
|
| | | RedPackDetailVO vo = new RedPackDetailVO();
|
| | | vo.setMonth(new RedPackMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1));
|
| | | finalList.add(vo);
|
| | | }
|
| | | RedPackDetailVO vo = new RedPackDetailVO();
|
| | | vo.setDetail(list.get(i));
|
| | | finalList.add(vo);
|
| | | }
|
| | | }
|
| | |
|
| | | // 统计月资金
|
| | |
|
| | | Map<Integer, RedPackDetailVO> monthMap = new TreeMap<>();
|
| | | if (finalList.size() > 1)
|
| | | for (int i = 0; i < finalList.size(); i++) {
|
| | | if (finalList.get(i).getMonth() != null)
|
| | | monthMap.put(i, finalList.get(i));
|
| | | }
|
| | |
|
| | | if (!monthMap.isEmpty()) {
|
| | | List<String> dateFormat = new ArrayList<>();
|
| | | Iterator<Integer> keys = monthMap.keySet().iterator();
|
| | | while (keys.hasNext()) {
|
| | | Integer key = keys.next();
|
| | | String date = "";
|
| | | date += monthMap.get(key).getMonth().getYear();
|
| | | date += "-";
|
| | | date += (monthMap.get(key).getMonth().getMonth() + "").length() < 2
|
| | | ? "0" + monthMap.get(key).getMonth().getMonth() : monthMap.get(key).getMonth().getMonth();
|
| | | dateFormat.add(date);
|
| | | }
|
| | | List<RedPackMonthVO> voList = redPackDetailMapper.selectMonthMoneyByUid(uid, dateFormat);
|
| | |
|
| | | int p = 0;
|
| | | keys = monthMap.keySet().iterator();
|
| | | while (keys.hasNext()) {
|
| | | Integer key = keys.next();
|
| | | |
| | | BigDecimal expend = new BigDecimal(voList.get(p).getExpend());
|
| | | BigDecimal income = new BigDecimal(voList.get(p).getIncome());
|
| | | |
| | | // 去除支出负号
|
| | | finalList.get(key).getMonth().setExpend(expend.setScale(2).toString().replace("-", ""));
|
| | | finalList.get(key).getMonth().setIncome(income.setScale(2).toString());
|
| | | p++;
|
| | | }
|
| | | }
|
| | | return finalList;
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public long countUserMoneyDetailForClient(Long uid, Long detailId, Date maxTime) {
|
| | | long monthCount = 0L;
|
| | | long detailCount = 0L;
|
| | | // 未通过时间筛选,查询所有
|
| | | if (maxTime == null) {
|
| | | detailCount = redPackDetailMapper.selectCountByUid(uid);
|
| | | // 用于表示当前所有
|
| | | monthCount = redPackDetailMapper.selectMonthCountByUid(uid, new Date(System.currentTimeMillis() + 1000 * 60 * 60L));
|
| | | } else {// 通过时间筛选了的,需要查询所有
|
| | | detailCount = redPackDetailMapper.selectCountByUidAndMaxCreateTime(uid, maxTime);
|
| | | monthCount = redPackDetailMapper.selectMonthCountByUid(uid, maxTime);
|
| | | }
|
| | |
|
| | | return monthCount + detailCount;
|
| | | }
|
| | | |
| | | |
| | | |
| | | |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.redpack.RedPackExchangeMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.common.AdminUser;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail.UserMoneyDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackExchange;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackExchangeService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.RedPackDetailFactory;
|
| | |
|
| | | @Service
|
| | | public class RedPackExchangeServiceImpl implements RedPackExchangeService {
|
| | |
|
| | | @Resource
|
| | | private RedPackExchangeMapper redPackExchangeMapper;
|
| | | |
| | | @Resource
|
| | | private RedPackConfigService redPackConfigService;
|
| | | |
| | | @Resource
|
| | | private RedPackBalanceService redPackBalanceService;
|
| | | |
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Resource
|
| | | private RedPackDetailService redPackDetailService;
|
| | | |
| | | |
| | | @Override
|
| | | public List<RedPackExchange> query(Integer start, Integer count, String key, Integer state){
|
| | | return redPackExchangeMapper.query(start, count, key, state);
|
| | | }
|
| | | |
| | | @Override
|
| | | public Long count(String key, Integer state){
|
| | | return redPackExchangeMapper.count(key, state);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<Long> countState(long uid){
|
| | | return redPackExchangeMapper.countState(uid);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<BigDecimal> countMoneyState(long uid){
|
| | | return redPackExchangeMapper.countMoneyState(uid);
|
| | | }
|
| | | |
| | | @Override
|
| | | public BigDecimal countMoneyByState(Long uid, Integer state){
|
| | | return redPackExchangeMapper.countMoneyByState(uid, state);
|
| | | }
|
| | | |
| | | @Override
|
| | | public RedPackExchange selectByPrimaryKey(long id){
|
| | | return redPackExchangeMapper.selectByPrimaryKey(id);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void exchangeCash(Long uid, BigDecimal amount) throws RedPackExchangeException {
|
| | | if (uid == null || amount == null)
|
| | | throw new RedPackExchangeException(1, "参数不正确");
|
| | |
|
| | | String extractBanlenMin = redPackConfigService.getValueByKey("extract_banlen_min");
|
| | | |
| | | BigDecimal balance = redPackBalanceService.getBalance(uid);
|
| | | if (balance == null || balance.compareTo(new BigDecimal(extractBanlenMin)) < 0)
|
| | | throw new RedPackExchangeException(1, "余额不足" + extractBanlenMin + "元");
|
| | | |
| | | if (balance.compareTo(amount) < 0)
|
| | | throw new RedPackExchangeException(1, "提现余额不足");
|
| | | |
| | | |
| | | String moneyMin = redPackConfigService.getValueByKey("extract_money_min");
|
| | | String moneyMax = redPackConfigService.getValueByKey("extract_money_max");
|
| | | if (amount.compareTo(new BigDecimal(moneyMin)) < 0 || amount.compareTo(new BigDecimal(moneyMax)) > 0)
|
| | | throw new RedPackExchangeException(1, "提现金额至少" + moneyMin + "元至多" + moneyMax + "元");
|
| | | |
| | | Date nowDate = new Date();
|
| | | |
| | | // 提现申请
|
| | | RedPackExchange exchange = new RedPackExchange();
|
| | | exchange.setUid(uid);
|
| | | exchange.setMoney(amount);
|
| | | exchange.setState(RedPackExchange.STATE_INIT);
|
| | | exchange.setCreateTime(nowDate);
|
| | | redPackExchangeMapper.insertSelective(exchange);
|
| | | |
| | | // 减少红包
|
| | | try {
|
| | | redPackBalanceService.subRedPack(uid, amount, RedPackDetailFactory.createExchange(exchange));
|
| | | } catch (Exception e) {
|
| | | throw new RedPackExchangeException(1, "红包信息异常");
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void passExchange(final long id, AdminUser admin) throws RedPackExchangeException {
|
| | | RedPackExchange record = redPackExchangeMapper.selectByPrimaryKey(id);
|
| | | if (record == null) |
| | | throw new RedPackExchangeException(1,"申请记录已不存在");
|
| | |
|
| | | if (RedPackExchange.STATE_INIT == record.getState())
|
| | | throw new RedPackExchangeException(1,"该申请已被处理,请刷新");
|
| | |
|
| | | Date nowDate = new Date();
|
| | | record.setAuditId(admin.getId());
|
| | | record.setAuditTime(nowDate);
|
| | | record.setState(RedPackExchange.STATE_SUCCESS);
|
| | | redPackExchangeMapper.updateByPrimaryKeySelective(record);
|
| | | |
| | | // 资金明细-添加资金
|
| | | UserMoneyDetail detail = new UserMoneyDetail();
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.redPackExchange.name() + ":" + record.getId()));
|
| | | detail.setMoney(record.getMoney());
|
| | | detail.setType(UserMoneyDetailTypeEnum.redPackExchange);
|
| | | detail.setTitle(UserMoneyDetailTypeEnum.redPackExchange.getDesc());
|
| | | detail.setDescInfo("于"+ TimeUtil.formatDate(record.getCreateTime()) +"提现");
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setUserInfo(new UserInfo(record.getUid()));
|
| | | |
| | | // 添加资金
|
| | | userMoneyService.addUserMoney(record.getUid(), record.getMoney(), detail);
|
| | | |
| | | try {
|
| | | String identifyCode = StringUtil.Md5(RedPackDetailTypeEnum.redExchangePass.name() + ":" + record.getId());
|
| | | RedPackDetail redPackDetail = redPackDetailService.getByIdentifyCode(identifyCode);
|
| | | RedPackDetail updateDetail = RedPackDetailFactory.updateExchangePass(redPackDetail.getId(), record);
|
| | | redPackDetailService.updateByPrimaryKeySelective(updateDetail);
|
| | | } catch (Exception e) {
|
| | | throw new RedPackExchangeException(1,"更新提现明细出错");
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void rejectExchange(long id, String reason, AdminUser admin) throws RedPackExchangeException {
|
| | | RedPackExchange record = redPackExchangeMapper.selectByPrimaryKey(id);
|
| | | if (record == null) |
| | | throw new RedPackExchangeException(1,"申请记录已不存在");
|
| | |
|
| | | if (RedPackExchange.STATE_INIT == record.getState())
|
| | | throw new RedPackExchangeException(1,"该申请已被处理,请刷新");
|
| | | |
| | | record.setReason(reason);
|
| | | record.setAuditTime(new Date());
|
| | | record.setAuditId(admin.getId());
|
| | | record.setState(RedPackExchange.STATE_REJECT);
|
| | | redPackExchangeMapper.updateByPrimaryKeySelective(record);
|
| | | |
| | | // 退回红包
|
| | | try {
|
| | | redPackBalanceService.addRedPack(record.getUid(), record.getMoney(), RedPackDetailFactory.createExchange(record));
|
| | | } catch (Exception e) {
|
| | | throw new RedPackExchangeException(1, "红包退回时出错");
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.redpack.RedPackGiveRecordMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.TokenRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.TokenRecord.TokenTypeEnum;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackGiveRecord;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackGiveRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.TokenRecordService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.TokenUtil;
|
| | | import com.yeshi.fanli.util.factory.RedPackDetailFactory;
|
| | |
|
| | | @Service
|
| | | public class RedPackGiveRecordServiceImpl implements RedPackGiveRecordService {
|
| | |
|
| | | @Resource
|
| | | private RedPackGiveRecordMapper redPackGiveRecordMapper;
|
| | |
|
| | | @Resource
|
| | | private RedPackConfigService redPackConfigService;
|
| | | |
| | | @Resource
|
| | | private RedPackBalanceService redPackBalanceService;
|
| | |
|
| | | |
| | | @Resource
|
| | | private TokenRecordService tokenRecordService;
|
| | | |
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public String giving(Long uid, BigDecimal amount) throws RedPackGiveRecordException {
|
| | | if (uid == null || amount == null)
|
| | | throw new RedPackGiveRecordException(1, "参数不正确");
|
| | |
|
| | | String giveMin = redPackConfigService.getValueByKey("give_money_min");
|
| | | String giveMax = redPackConfigService.getValueByKey("give_money_max");
|
| | | if (amount.compareTo(new BigDecimal(giveMin)) < 0 || amount.compareTo(new BigDecimal(giveMax)) > 0)
|
| | | throw new RedPackGiveRecordException(1, "赠送金额至少" + giveMin + "元至多" + giveMax + "元");
|
| | | |
| | | BigDecimal balance = redPackBalanceService.getBalance(uid);
|
| | | if (balance == null || amount.compareTo(balance) > 0)
|
| | | throw new RedPackGiveRecordException(1, "余额不足");
|
| | |
|
| | | Date nowDate = new Date();
|
| | | // 赠送记录
|
| | | RedPackGiveRecord giveRecord = new RedPackGiveRecord();
|
| | | giveRecord.setAmount(amount);
|
| | | giveRecord.setGiveUid(uid);
|
| | | giveRecord.setState(RedPackGiveRecord.STATE_INIT);
|
| | | giveRecord.setGiveTime(nowDate);
|
| | | giveRecord.setEndTime(DateUtil.plusDayDate(Constant.GIVE_DAYS, new Date()));
|
| | | redPackGiveRecordMapper.insertSelective(giveRecord);
|
| | |
|
| | | // 口令记录
|
| | | TokenRecord tokenRecord = new TokenRecord();
|
| | | tokenRecord.setUid(uid);
|
| | | tokenRecord.setIdentify(giveRecord.getId() + "");
|
| | | tokenRecord.setType(TokenTypeEnum.redPack);
|
| | | tokenRecord.setStartTime(nowDate);
|
| | | tokenRecord.setEndTime(DateUtil.plusDayDate(Constant.TOKEN_DAYS, new Date()));
|
| | | tokenRecord.setState(0);
|
| | | tokenRecordService.insertSelective(tokenRecord);
|
| | |
|
| | | // 创建口令
|
| | | String token = TokenUtil.createToken(tokenRecord.getId());
|
| | | tokenRecord.setToken(token);
|
| | | tokenRecordService.updateByPrimaryKeySelective(tokenRecord);
|
| | |
|
| | | String tips = redPackConfigService.getValueByKey("give_tips");
|
| | | String projectChineseName = Constant.systemCommonConfig.getProjectChineseName();
|
| | | while (tips.contains("{APP名称}")) {
|
| | | tips = tips.replace("{APP名称}", projectChineseName);
|
| | | }
|
| | | tips = tips.replace("{口令}", token).replace("{下载链接}", redPackConfigService.getValueByKey("app_down_link")).replace("{面额}",
|
| | | amount.setScale(0).toString());
|
| | | |
| | | // 减少红包
|
| | | try {
|
| | | redPackBalanceService.subRedPack(uid, amount, RedPackDetailFactory.createGiveOthers(giveRecord, null, RedPackDetailTypeEnum.giveOthers));
|
| | | } catch (Exception e) {
|
| | | throw new RedPackGiveRecordException(1, "红包创建失败");
|
| | | }
|
| | | return tips;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | |
|
| | | import com.yeshi.fanli.entity.redpack.RedPackBalance;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
|
| | |
|
| | | public interface RedPackBalanceService {
|
| | |
|
| | | /**
|
| | | * 查询用户余额信息
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public RedPackBalance selectByPrimaryKey(Long uid);
|
| | |
|
| | | /**
|
| | | * 获取用户余额
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getBalance(Long uid);
|
| | |
|
| | | /**
|
| | | * 添加红包
|
| | | * @param uid
|
| | | * @param money
|
| | | */
|
| | | public void addRedPack(Long uid, BigDecimal money);
|
| | | |
| | | /**
|
| | | * 添加红包
|
| | | * @param uid
|
| | | * @param money
|
| | | */
|
| | | public void addRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException;
|
| | |
|
| | | /**
|
| | | * 减少红包
|
| | | * @param uid
|
| | | * @param money
|
| | | */
|
| | | public void subRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException;
|
| | |
|
| | | |
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.redpack;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.entity.redpack.RedPackConfig;
|
| | |
|
| | | public interface RedPackConfigService {
|
| | |
|
| | | /**
|
| | | * 根据key值查询
|
| | | * |
| | | * @param key
|
| | | * @return
|
| | | */
|
| | | public RedPackConfig getByKey(String key);
|
| | |
|
| | | /**
|
| | | * 根据key值 获取value
|
| | | * |
| | | * @param key
|
| | | * @return
|
| | | */
|
| | | public String getValueByKey(String key);
|
| | |
|
| | | |
| | | public RedPackConfig getByKey(String key, Date date);
|
| | |
|
| | | |
| | | public String getValueByKey(String key, Date date);
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail;
|
| | | import com.yeshi.fanli.vo.redpack.RedPackDetailVO;
|
| | |
|
| | | public interface RedPackDetailService {
|
| | |
|
| | | /**
|
| | | * 查询明细记录
|
| | | * @param uid
|
| | | * @param detailId
|
| | | * @param maxTime
|
| | | * @return
|
| | | */
|
| | | public List<RedPackDetailVO> listUserMoneyDetailForClient(Long uid, Long detailId, Date maxTime);
|
| | |
|
| | | public long countUserMoneyDetailForClient(Long uid, Long detailId, Date maxTime);
|
| | |
|
| | | /**
|
| | | * 创建明细
|
| | | * @param record
|
| | | */
|
| | | public void insertSelective(RedPackDetail record);
|
| | | |
| | | /**
|
| | | * 更新明细
|
| | | * @param record
|
| | | */
|
| | | public void updateByPrimaryKeySelective(RedPackDetail record);
|
| | |
|
| | |
|
| | | /**
|
| | | * 根据日期类型统计获得金额
|
| | | * @param uid
|
| | | * @param dateType 1今日 、2昨日、3本月、4上月
|
| | | * @return
|
| | | */
|
| | | public BigDecimal countAddMoneyByDate(long uid, int dateType);
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 根据日期类型统计消耗金额
|
| | | * @param uid
|
| | | * @param dateType 1今日 、2昨日、3本月、4上月
|
| | | * @return
|
| | | */
|
| | | public BigDecimal countUseMoneyByDate(long uid, int dateType);
|
| | |
|
| | | /**
|
| | | * 根据唯一标识查询
|
| | | * @param identifyCode
|
| | | * @return
|
| | | */
|
| | | public RedPackDetail getByIdentifyCode(String identifyCode);
|
| | |
|
| | |
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.common.AdminUser;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackExchange;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
|
| | |
|
| | | public interface RedPackExchangeService {
|
| | |
|
| | | /**
|
| | | * 提现转换现金
|
| | | * @param uid
|
| | | * @param amount
|
| | | * @throws RedPackExchangeException
|
| | | */
|
| | | public void exchangeCash(Long uid, BigDecimal amount) throws RedPackExchangeException;
|
| | |
|
| | | /**
|
| | | * 后台查询
|
| | | * @param start
|
| | | * @param count
|
| | | * @param key
|
| | | * @param state
|
| | | * @return
|
| | | */
|
| | | public List<RedPackExchange> query(Integer start, Integer count, String key, Integer state);
|
| | |
|
| | | public Long count(String key, Integer state);
|
| | |
|
| | | /**
|
| | | * 统计各个状态
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public List<Long> countState(long uid);
|
| | |
|
| | | /**
|
| | | * 统计各个状态金额
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public List<BigDecimal> countMoneyState(long uid);
|
| | |
|
| | | /**
|
| | | * 获取申请
|
| | | * @param id
|
| | | * @return
|
| | | */
|
| | | public RedPackExchange selectByPrimaryKey(long id);
|
| | |
|
| | | /**
|
| | | * 提现通过
|
| | | * @param id
|
| | | * @param admin
|
| | | * @throws RedPackExchangeException
|
| | | */
|
| | | public void passExchange(long id, AdminUser admin) throws RedPackExchangeException;
|
| | |
|
| | | /**
|
| | | * 提现拒绝
|
| | | * @param id
|
| | | * @param reason
|
| | | * @param admin
|
| | | * @throws RedPackExchangeException
|
| | | */
|
| | | public void rejectExchange(long id, String reason, AdminUser admin) throws RedPackExchangeException;
|
| | |
|
| | | /**
|
| | | * 统计状态
|
| | | * @param uid
|
| | | * @param state
|
| | | * @return
|
| | | */
|
| | | public BigDecimal countMoneyByState(Long uid, Integer state);
|
| | |
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | |
|
| | | import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
|
| | |
|
| | | public interface RedPackGiveRecordService {
|
| | |
|
| | | /**
|
| | | * 赠送红包
|
| | | * @param uid
|
| | | * @param amount
|
| | | * @return
|
| | | * @throws RedPackGiveRecordException
|
| | | */
|
| | | public String giving(Long uid, BigDecimal amount) throws RedPackGiveRecordException;
|
| | |
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.factory;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackExchange;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackGiveRecord;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackDetailException;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | public class RedPackDetailFactory {
|
| | |
|
| | | /**
|
| | | * 红包提现
|
| | | * |
| | | * @param extract
|
| | | * @return
|
| | | */
|
| | | public static RedPackDetail createExchange(RedPackExchange exchange) throws RedPackDetailException {
|
| | | if (exchange == null)
|
| | | throw new RedPackDetailException(1, "提现记录不能为空");
|
| | | |
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(false);
|
| | | detail.setDesc( "等待人工审核");
|
| | | detail.setUid(exchange.getUid());
|
| | | detail.setMoney(new BigDecimal("-" + exchange.getMoney()));
|
| | | detail.setType(RedPackDetailTypeEnum.redExchange);
|
| | | detail.setTitle(RedPackDetailTypeEnum.redExchange.getDesc());
|
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redExchange.name() + ":" + exchange.getId()));
|
| | | detail.setCreateTime(new Date());
|
| | | return detail;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 红包提现通过
|
| | | * |
| | | * @param extract
|
| | | * @return
|
| | | */
|
| | | public static RedPackDetail updateExchangePass(Long id, RedPackExchange exchange) throws RedPackDetailException {
|
| | | if (id == null)
|
| | | throw new RedPackDetailException(1, "明细ID不能为空");
|
| | | |
| | | if (exchange == null)
|
| | | throw new RedPackDetailException(1, "提现记录不能为空");
|
| | | |
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setId(id);
|
| | | detail.setDisplay(true);
|
| | | detail.setDesc("请到账户余额中查看");
|
| | | detail.setType(RedPackDetailTypeEnum.redExchangePass);
|
| | | detail.setTitle(RedPackDetailTypeEnum.redExchangePass.getDesc());
|
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redExchangePass.name() + ":" + exchange.getId()));
|
| | | return detail;
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 红包提现拒绝
|
| | | * |
| | | * @param extract
|
| | | * @return
|
| | | */
|
| | | public static RedPackDetail createExchangeReject(RedPackExchange exchange) throws RedPackDetailException {
|
| | | if (exchange == null)
|
| | | throw new RedPackDetailException(1, "提现记录不能为空");
|
| | | |
| | | // 红包明细- 退回红包
|
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(false);
|
| | | detail.setUid(exchange.getUid());
|
| | | detail.setMoney(exchange.getMoney());
|
| | | detail.setDesc("红包产生过程中涉嫌违规");
|
| | | detail.setTitle(RedPackDetailTypeEnum.redExchangeReject.getDesc());
|
| | | detail.setType(RedPackDetailTypeEnum.redExchangeReject);
|
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redExchangeReject.name() + ":" + exchange.getId()));
|
| | | detail.setCreateTime(new Date());
|
| | | return detail;
|
| | | }
|
| | | |
| | | |
| | | |
| | | public static RedPackDetail createGiveOthers(RedPackGiveRecord giveRecord, String desc, RedPackDetailTypeEnum type) throws RedPackDetailException {
|
| | | if (giveRecord == null || type == null)
|
| | | throw new RedPackDetailException(1, "提现记录、类型不能为空");
|
| | | |
| | | // 红包明细- 退回红包
|
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(true);
|
| | | detail.setUid(giveRecord.getGiveUid());
|
| | | detail.setMoney(giveRecord.getAmount());
|
| | | detail.setDesc(desc);
|
| | | detail.setType(type);
|
| | | detail.setTitle(type.getDesc());
|
| | | detail.setIdentifyCode(StringUtil.Md5(type.name() + ":" + giveRecord.getId()));
|
| | | detail.setCreateTime(new Date());
|
| | | return detail;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.mybatishandler.redpack;
|
| | |
|
| | | import java.sql.CallableStatement;
|
| | | import java.sql.PreparedStatement;
|
| | | import java.sql.ResultSet;
|
| | | import java.sql.SQLException;
|
| | |
|
| | | import org.apache.ibatis.type.BaseTypeHandler;
|
| | | import org.apache.ibatis.type.JdbcType;
|
| | |
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
|
| | |
|
| | |
|
| | | public class RedPackDetailTypeEnumHandler extends BaseTypeHandler<RedPackDetailTypeEnum> {
|
| | |
|
| | | @Override
|
| | | public RedPackDetailTypeEnum getNullableResult(ResultSet arg0, String arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | return RedPackDetailTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public RedPackDetailTypeEnum getNullableResult(ResultSet arg0, int arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | // 根据数据库中的key值,定位SexEnum子类
|
| | | return RedPackDetailTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public RedPackDetailTypeEnum getNullableResult(CallableStatement arg0, int arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | // 根据数据库中的key值,定位SexEnum子类
|
| | | return RedPackDetailTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void setNonNullParameter(PreparedStatement arg0, int arg1, RedPackDetailTypeEnum arg2, JdbcType arg3)
|
| | | throws SQLException {
|
| | | arg0.setString(arg1, arg2.name());
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.vo.goods;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | |
|
| | | public class SpikeTimeVO {
|
| | | // 显示时间
|
| | | @Expose
|
| | | private String time;
|
| | | // 状态
|
| | | @Expose
|
| | | private String state;
|
| | | // 选中
|
| | | @Expose
|
| | | private boolean checked;
|
| | | |
| | | @Expose
|
| | | private String requestTime;
|
| | |
|
| | | public String getTime() {
|
| | | return time;
|
| | | }
|
| | |
|
| | | public void setTime(String time) {
|
| | | this.time = time;
|
| | | }
|
| | |
|
| | | public String getState() {
|
| | | return state;
|
| | | }
|
| | |
|
| | | public void setState(String state) {
|
| | | this.state = state;
|
| | | }
|
| | |
|
| | | public boolean isChecked() {
|
| | | return checked;
|
| | | }
|
| | |
|
| | | public void setChecked(boolean checked) {
|
| | | this.checked = checked;
|
| | | }
|
| | |
|
| | | public String getRequestTime() {
|
| | | return requestTime;
|
| | | }
|
| | |
|
| | | public void setRequestTime(String requestTime) {
|
| | | this.requestTime = requestTime;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.vo.redpack;
|
| | |
|
| | | import java.io.Serializable;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail;
|
| | |
|
| | | public class RedPackDetailVO implements Serializable{
|
| | | |
| | | /**
|
| | | * |
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | | |
| | | @Expose
|
| | | private RedPackMonthVO month;
|
| | | @Expose
|
| | | private RedPackDetail detail;
|
| | |
|
| | | public RedPackMonthVO getMonth() {
|
| | | return month;
|
| | | }
|
| | |
|
| | | public void setMonth(RedPackMonthVO month) {
|
| | | this.month = month;
|
| | | }
|
| | |
|
| | | public RedPackDetail getDetail() {
|
| | | return detail;
|
| | | }
|
| | |
|
| | | public void setDetail(RedPackDetail detail) {
|
| | | this.detail = detail;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.vo.redpack;
|
| | |
|
| | | import java.io.Serializable;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | |
|
| | | public class RedPackMonthVO implements Serializable{
|
| | | /**
|
| | | * |
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | | |
| | | @Expose
|
| | | private int year;// 年份
|
| | | @Expose
|
| | | private int month;// 月
|
| | | @Expose
|
| | | private String expend;// 支出
|
| | | @Expose
|
| | | private String income;// 收入
|
| | |
|
| | | private String dateFormate;
|
| | |
|
| | | public String getDateFormate() {
|
| | | return dateFormate;
|
| | | }
|
| | |
|
| | | public void setDateFormate(String dateFormate) {
|
| | | this.dateFormate = dateFormate;
|
| | | }
|
| | |
|
| | | public RedPackMonthVO(int year, int month) {
|
| | | this.year = year;
|
| | | this.month = month;
|
| | | }
|
| | |
|
| | | public RedPackMonthVO() {
|
| | |
|
| | | }
|
| | |
|
| | | public int getYear() {
|
| | | return year;
|
| | | }
|
| | |
|
| | | public void setYear(int year) {
|
| | | this.year = year;
|
| | | }
|
| | |
|
| | | public int getMonth() {
|
| | | return month;
|
| | | }
|
| | |
|
| | | public void setMonth(int month) {
|
| | | this.month = month;
|
| | | }
|
| | |
|
| | | public String getExpend() {
|
| | | return expend;
|
| | | }
|
| | |
|
| | | public void setExpend(String expend) {
|
| | | this.expend = expend;
|
| | | }
|
| | |
|
| | | public String getIncome() {
|
| | | return income;
|
| | | }
|
| | |
|
| | | public void setIncome(String income) {
|
| | | this.income = income;
|
| | | }
|
| | | }
|
| | |
| | | */
|
| | | public class RedPackRecord {
|
| | | // openId
|
| | | @CsvBindByName(column = "用户openid", required = true)
|
| | | @CsvBindByName(column = "用户openid")
|
| | | private String openId;
|
| | | // 交易订单号
|
| | | @CsvBindByName(column = "商户订单号")
|