Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div
# Conflicts:
# fanli/src/main/java/com/yeshi/fanli/entity/money/UserMoneyDetail.java
# fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractServiceImpl.java
2个文件已删除
45个文件已修改
33个文件已添加
| | |
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping("getSchedulerList")
|
| | | public void getSchedulerList(PrintWriter out) {
|
| | | try {
|
| | | for (String groupName : scheduler.getJobGroupNames()) {
|
| | | System.out.println(groupName);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private LostOrderService lostOrderService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | /**
|
| | | * 订单列表
|
| | |
| | | if (endTime != null && endTime.trim().length() > 0) {
|
| | | endTime += " 23:59:59";
|
| | | }
|
| | |
|
| | | // 判断是否需要显示订单找回提示
|
| | | if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | if (state == 0 && page == 1) {
|
| | | if (redisManager.frequencyLimit("orderlist-" + acceptData.getDevice(), 15, 3)) {// 15秒内请求3次触发
|
| | | // TODO 显示订单找回提醒
|
| | | }
|
| | | }
|
| | |
|
| | | try {
|
| | | long count = 0;
|
| | |
| | | Date maxGetTime = new Date(nowTime);
|
| | | inviteMoney = hongBaoV2CountService.sumAlreadyGetMoneyByUid(uid, inviteTypes, minGetTime, maxGetTime);
|
| | | inviteCount = hongBaoV2CountService.countAlreadyGetMoneyByUid(uid, inviteTypes, minGetTime, maxGetTime);
|
| | | |
| | |
|
| | | sharemoney = hongBaoV2CountService.sumAlreadyGetMoneyByUid(uid, shareTypes, minGetTime, maxGetTime);
|
| | | shareCount = hongBaoV2CountService.countAlreadyGetMoneyByUid(uid, shareTypes, minGetTime, maxGetTime);
|
| | |
|
| | |
| | | String imei = acceptData.getImei();
|
| | | result = guessLikeDeviceTB(idfa, imei, page);
|
| | | } else {
|
| | | result = commonTemplateContentService.getContentList(type, cid, page, Constant.PAGE_SIZE);
|
| | | // 大淘客页码只能为10,50,100,200
|
| | | result = commonTemplateContentService.getContentList(type, cid, page, 10);
|
| | | }
|
| | |
|
| | | JSONObject root = new JSONObject();
|
| | |
| | | List<SwiperPicture> bannerList = new ArrayList<>();
|
| | | root.put("bannerList", new Gson().toJson(bannerList));
|
| | | }
|
| | | |
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
|
| | | List<TaoBaoGoodsBrief> goodsList = result.getGoodsList();
|
| | |
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 猜你喜欢-淘宝设备推荐
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @return
|
| | |
| | | @Cacheable(value = "commonContentCache", key = "#idfa+'-'+#imei+'-'+#page")
|
| | | private CommonContentResult guessLikeDeviceTB(String idfa, String imei, Integer page) {
|
| | | TaoBaoSearchResult searchResult = TaoKeApiUtil.guessDeviceLike(page, Constant.PAGE_SIZE, imei, idfa);
|
| | | if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null |
| | | if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null
|
| | | && searchResult.getTaoBaoGoodsBriefs().size() > 0) {
|
| | | CommonContentResult result = new CommonContentResult();
|
| | | result.setCount(searchResult.getPageEntity().getTotalCount());
|
| | |
| | | data.put("baichuan", false);// 不需要采用阿里百川的方式加载webview
|
| | | data.put("goodsDetail", false);// 不需要拦截商品详情
|
| | | }
|
| | | if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | JSONObject js = new JSONObject();
|
| | | String jsStr = configService.get("url_extract_id");
|
| | | String md5 = StringUtil.Md5(jsStr);
|
| | | js.put("md5", md5);
|
| | | data.put("js", js);
|
| | | }
|
| | | //TODO 前端需要处理 |
| | | // if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | // JSONObject js = new JSONObject();
|
| | | // String jsStr = configService.get("url_extract_id");
|
| | | // String md5 = StringUtil.Md5(jsStr);
|
| | | // js.put("md5", md5);
|
| | | // data.put("js", js);
|
| | | // }
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
| | | List<HongBaoV2> listChildrenById(Long id); |
| | | |
| | | /** |
| | | * 获取子红包列表 |
| | | * @param idList |
| | | * @return |
| | | */ |
| | | List<HongBaoV2> listChildrenByIds(@Param("idList") List<Long> idList); |
| | | /** |
| | | * 获取奖金列表(1.4.9之前) |
| | | * |
| | | * @param uid |
| | |
| | | * @param count |
| | | * @return |
| | | */ |
| | | List<HongBaoV2> listCanBalanceHongBaoByTypeAndUid(@Param("types") List<Integer> type, @Param("uid") Long uid, |
| | | List<HongBaoV2> listCanBalanceHongBaoByTypeAndUid(@Param("types") List<Integer> type, @Param("uid") Long uid, @Param("orderType") Integer orderType, |
| | | @Param("start") long start, @Param("count") int count); |
| | | |
| | | /** |
| | |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | long countCanBalanceHongBaoByTypeAndUid(@Param("types") List<Integer> type, @Param("uid") Long uid); |
| | | long countCanBalanceHongBaoByTypeAndUid(@Param("types") List<Integer> type, @Param("uid") Long uid, @Param("orderType") Integer orderType); |
| | | |
| | | /** |
| | | * 根据用户ID,订单状态和结算时间统计邀请赚的订单数量 |
| | |
| | | */ |
| | | List<HongBaoV2> listByStateAndTypeAndUid(@Param("stateList") List<Integer> stateList, |
| | | @Param("typeList") List<Integer> typeList, @Param("uid") Long uid,@Param("start") long start,@Param("count")int count); |
| | | |
| | | |
| | | /** |
| | | * 根据ID批量查询 |
| | | * @param idList |
| | | * @return |
| | | */ |
| | | List<HongBaoV2> listByIds(@Param("idList") List<Long> idList); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.hongbao; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.order.HongBaoV2SettleTemp; |
| | | |
| | | public interface HongBaoV2SettleTempMapper extends BaseMapper<HongBaoV2SettleTemp> { |
| | | |
| | | /** |
| | | * 根据Key检索 |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | List<HongBaoV2SettleTemp> listByKey(String key); |
| | | |
| | | long countByKey(String key); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.money; |
| | | |
| | | 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.money.InviteOrderSubsidyDebt; |
| | | |
| | | public interface InviteOrderSubsidyDebtMapper extends BaseMapper<InviteOrderSubsidyDebt> { |
| | | |
| | | /** |
| | | * 检索(根据剩余资金与用户ID) |
| | | * |
| | | * @param minMoney |
| | | * @param maxMoney |
| | | * @param uid |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | List<InviteOrderSubsidyDebt> listByLeftMoneyAndUid(@Param("minMoney") BigDecimal minMoney, |
| | | @Param("maxMoney") BigDecimal maxMoney, @Param("uid") Long uid, @Param("start") long start, |
| | | @Param("count") int count); |
| | | |
| | | /** |
| | | * 检索(根据剩余资金与用户ID) |
| | | * |
| | | * @param minMoney |
| | | * @param maxMoney |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | long countByLeftMoneyAndUid(@Param("minMoney") BigDecimal minMoney, @Param("maxMoney") BigDecimal maxMoney, |
| | | @Param("uid") Long uid); |
| | | |
| | | InviteOrderSubsidyDebt selectByPrimaryKeyForUpdate(Long id); |
| | | |
| | | /** |
| | | * 计算欠款金额(根据用户ID) |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | BigDecimal sumLeftMoneyByUid(Long uid); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.money; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebtRepayHistory; |
| | | |
| | | public interface InviteOrderSubsidyDebtRepayHistoryMapper extends BaseMapper<InviteOrderSubsidyDebtRepayHistory> { |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.mq; |
| | | |
| | | 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.mq.MQUnSendInfo; |
| | | |
| | | public interface MQUnSendInfoMapper extends BaseMapper<MQUnSendInfo> { |
| | | |
| | | MQUnSendInfo selectByTopicTagAndKey(@Param("topic") String topic, @Param("tag") String tag, |
| | | @Param("key") String key); |
| | | |
| | | /** |
| | | * 根据最大发送时间检索 |
| | | * |
| | | * @param maxSendTime |
| | | * @param start |
| | | * @param count |
| | | * @return |
| | | */ |
| | | List<MQUnSendInfo> listByMaxSendTime(@Param("maxSendTime") Date maxSendTime, @Param("start") long start, |
| | | @Param("count") int count); |
| | | |
| | | } |
| | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2; |
| | | import com.yeshi.fanli.entity.order.CommonOrder; |
| | | import com.yeshi.fanli.entity.order.HongBaoOrder; |
| | | |
| | | public interface HongBaoOrderMapper extends BaseMapper<HongBaoOrder> { |
| | |
| | | */ |
| | | public int countWeiQuanOrderWithMinCommision(@Param("uid")Long uid,@Param("minMoney") BigDecimal minMoney,@Param("minTime") Date minTime); |
| | | |
| | | |
| | | /** |
| | | * 根据订单ID与来源类型查询 |
| | | * @param orderId |
| | | * @param sourceType |
| | | * @return |
| | | */ |
| | | public List<HongBaoOrder> listByOrderIdAndSourceType(@Param("orderId") String orderId, |
| | | @Param("sourceType") int sourceType); |
| | | } |
| | |
| | | package com.yeshi.fanli.dao.mybatis.order; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | |
| | | |
| | | /** |
| | | * 查询用户补贴 |
| | | * |
| | | * @param uid |
| | | * @param orderNo |
| | | * @param Type |
| | | * @return |
| | | */ |
| | | InviteOrderSubsidy getByOrderNoAndType(@Param("uid")Long uid, @Param("orderNo")String orderNo,@Param("type") Integer type); |
| | | InviteOrderSubsidy getByOrderNoAndType(@Param("uid") Long uid, @Param("orderNo") String orderNo, |
| | | @Param("type") Integer type); |
| | | |
| | | /** |
| | | * 查询加锁 |
| | | * |
| | | * @param uid |
| | | * @param orderNo |
| | | * @param type |
| | | * @return |
| | | */ |
| | | InviteOrderSubsidy getByOrderNoAndTypeForUpdate(@Param("uid") Long uid, @Param("orderNo") String orderNo, |
| | | @Param("type") Integer type); |
| | | |
| | | /** |
| | | * 根据订单号与来源类型查询 |
| | | * |
| | | * @param orderNo |
| | | * @param type |
| | | * @return |
| | | */ |
| | | long countByOrderNoAndType(@Param("orderNo") String orderNo, @Param("type") Integer type); |
| | | |
| | | /** |
| | | * 根据订单号与来源类型查询 |
| | | * |
| | | * @param orderNo |
| | | * @param type |
| | | * @return |
| | | */ |
| | | List<InviteOrderSubsidy> listByOrderNoAndType(@Param("orderNo") String orderNo, @Param("type") Integer type); |
| | | } |
| | |
| | | package com.yeshi.fanli.dao.mybatis.order; |
| | | |
| | | 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.order.OrderHongBaoMap; |
| | | |
| | | public interface OrderHongBaoMapMapper extends BaseMapper<OrderHongBaoMap>{ |
| | | public interface OrderHongBaoMapMapper extends BaseMapper<OrderHongBaoMap> { |
| | | |
| | | /** |
| | | * 获取奖励金额 |
| | | * |
| | | * @param orderNo |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | BigDecimal getCouponHongbaoByOrderNo(@Param("orderNo")String orderNo, @Param("uid")Long uid); |
| | | BigDecimal getCouponHongbaoByOrderNo(@Param("orderNo") String orderNo, @Param("uid") Long uid); |
| | | |
| | | /** |
| | | * 根据订单号查询 |
| | | * |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | List<OrderHongBaoMap> listByOrderId(Long orderId); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dto.order;
|
| | |
|
| | | /**
|
| | | * 红包MQ消息
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class OrderMQMsgDTO {
|
| | | private String orderId;
|
| | | private Integer type;
|
| | | private Long uid;
|
| | |
|
| | | public OrderMQMsgDTO(String orderId, Integer type, Long uid) {
|
| | | this.orderId = orderId;
|
| | | this.type = type;
|
| | | this.uid = uid;
|
| | | }
|
| | | |
| | | public OrderMQMsgDTO() {
|
| | | |
| | | }
|
| | |
|
| | |
|
| | | public String getOrderId() {
|
| | | return orderId;
|
| | | }
|
| | |
|
| | | public void setOrderId(String orderId) {
|
| | | this.orderId = orderId;
|
| | | }
|
| | |
|
| | | public Integer getType() {
|
| | | return type;
|
| | | }
|
| | |
|
| | | public void setType(Integer type) {
|
| | | this.type = type;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dto.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | /**
|
| | | * 订单到账MQ消息
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class OrderMoneyRecievedMQMsgDTO {
|
| | | public static final int TYPE_ZIGOU = 1;// 自购到账
|
| | | public static final int TYPE_SHARE = 2;// 分享到账
|
| | | public static final int TYPE_INVITE = 3;// 邀请到账
|
| | | private int type;// 到账类型
|
| | | private Long uid;
|
| | | private Integer sourceType;// 订单来源类型
|
| | | private String orderId;// 订单号
|
| | | private BigDecimal money;// 到账金额
|
| | | private Date date;// 到账时间
|
| | |
|
| | | public OrderMoneyRecievedMQMsgDTO() {
|
| | |
|
| | | }
|
| | |
|
| | | public OrderMoneyRecievedMQMsgDTO(int type, Long uid, Integer sourceType, String orderId, BigDecimal money,
|
| | | Date date) {
|
| | | this.type = type;
|
| | | this.uid = uid;
|
| | | this.sourceType = sourceType;
|
| | | this.orderId = orderId;
|
| | | this.money = money;
|
| | | this.date = date;
|
| | | }
|
| | |
|
| | | public int getType() {
|
| | | return type;
|
| | | }
|
| | |
|
| | | public void setType(int type) {
|
| | | this.type = type;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public Integer getSourceType() {
|
| | | return sourceType;
|
| | | }
|
| | |
|
| | | public void setSourceType(Integer sourceType) {
|
| | | this.sourceType = sourceType;
|
| | | }
|
| | |
|
| | | public String getOrderId() {
|
| | | return orderId;
|
| | | }
|
| | |
|
| | | public void setOrderId(String orderId) {
|
| | | this.orderId = orderId;
|
| | | }
|
| | |
|
| | | public BigDecimal getMoney() {
|
| | | return money;
|
| | | }
|
| | |
|
| | | public void setMoney(BigDecimal money) {
|
| | | this.money = money;
|
| | | }
|
| | |
|
| | | public Date getDate() {
|
| | | return date;
|
| | | }
|
| | |
|
| | | public void setDate(Date date) {
|
| | | this.date = date;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dto.user.coupon;
|
| | |
|
| | | /**
|
| | | * 用券的mq消息实体
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class UserSystemCouponUseMQMsgDTO {
|
| | | private Long userSystemCouponId;// 用户的券ID
|
| | | private String orderId;// 订单号
|
| | | private Integer sourceType;// 订单来源
|
| | |
|
| | | public UserSystemCouponUseMQMsgDTO(Long userSystemCouponId, String orderId, Integer sourceType) {
|
| | | this.userSystemCouponId = userSystemCouponId;
|
| | | this.orderId = orderId;
|
| | | this.sourceType = sourceType;
|
| | | }
|
| | | |
| | | public UserSystemCouponUseMQMsgDTO() {
|
| | | |
| | | }
|
| | |
|
| | | public Long getUserSystemCouponId() {
|
| | | return userSystemCouponId;
|
| | | }
|
| | |
|
| | | public void setUserSystemCouponId(Long userSystemCouponId) {
|
| | | this.userSystemCouponId = userSystemCouponId;
|
| | | }
|
| | |
|
| | | public String getOrderId() {
|
| | | return orderId;
|
| | | }
|
| | |
|
| | | public void setOrderId(String orderId) {
|
| | | this.orderId = orderId;
|
| | | }
|
| | |
|
| | | public Integer getSourceType() {
|
| | | return sourceType;
|
| | | }
|
| | |
|
| | | public void setSourceType(Integer sourceType) {
|
| | | this.sourceType = sourceType;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | public final static int STATE_KELINGQU = 2;
|
| | | public final static int STATE_YILINGQU = 3;
|
| | | public final static int STATE_SHIXIAO = 4;
|
| | | |
| | |
|
| | | // 5-部分失效(返回客户端显示用,不用作逻辑处理)
|
| | | public final static int STATE_BUFENSHIXIAO = 5;
|
| | |
|
| | | // 自购红包 老版 2属于自购
|
| | | // 自购红包 老版 2属于自购
|
| | | public final static int TYPE_ZIGOU = 1;
|
| | | // 活动红包
|
| | | public final static int TYPE_HUODONG = 3;
|
| | | // 新人红包
|
| | | public final static int TYPE_XINREN = 4;
|
| | | |
| | |
|
| | | // 使用券红包
|
| | | public final static int TYPE_COUPON = 10;
|
| | | |
| | |
|
| | | public final static int TYPE_YAOQING = 5;
|
| | | // 一级分销红包
|
| | | public final static int TYPE_YIJI = 6;
|
| | | // 二级分销红包
|
| | | public final static int TYPE_ERJI = 7;
|
| | | |
| | |
|
| | | // 分享商品得来的红包
|
| | | public final static int TYPE_SHARE_GOODS = 20;
|
| | | // 一级分享赚分销红包
|
| | |
| | |
|
| | | // 金币兑换红包
|
| | | public final static int TYPE_EXCHANGE = 30;
|
| | | |
| | | //饿了么红包
|
| | | public final static int TYPE_ELME=25;
|
| | |
|
| | | // 饿了么红包
|
| | | public final static int TYPE_ELME = 25;
|
| | |
|
| | | @Column(name = "hb_id")
|
| | | private Long id;
|
| | |
| | | // 更新时间
|
| | | @Column(name = "cog_update_time")
|
| | | private Date updateTime;
|
| | |
|
| | | // 订单类型
|
| | | @Column(name = "cog_order_type")
|
| | | private Integer orderType;
|
| | |
|
| | | public HongBaoV2() {
|
| | |
|
| | |
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | public Integer getOrderType() {
|
| | | return orderType;
|
| | | }
|
| | |
|
| | | public void setOrderType(Integer orderType) {
|
| | | this.orderType = orderType;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 订单补贴欠账
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_ec_invite_order_subsidy_debt")
|
| | | public class InviteOrderSubsidyDebt {
|
| | | @Column(name = "sd_id")
|
| | | private Long id;
|
| | | @Column(name = "sd_uid")
|
| | | private Long uid;
|
| | | @Column(name = "sd_origin_money")
|
| | | private BigDecimal originMoney;
|
| | | @Column(name = "sd_left_money")
|
| | | private BigDecimal leftMoney;
|
| | | @Column(name = "sd_source_id")
|
| | | private Long sourceId;
|
| | | @Column(name = "sd_beizhu")
|
| | | private String beiZhu;
|
| | | @Column(name = "sd_create_time")
|
| | | private Date createTime;
|
| | | @Column(name = "sd_update_time")
|
| | | private Date updateTime;
|
| | |
|
| | | 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 getOriginMoney() {
|
| | | return originMoney;
|
| | | }
|
| | |
|
| | | public void setOriginMoney(BigDecimal originMoney) {
|
| | | this.originMoney = originMoney;
|
| | | }
|
| | |
|
| | | public BigDecimal getLeftMoney() {
|
| | | return leftMoney;
|
| | | }
|
| | |
|
| | | public void setLeftMoney(BigDecimal leftMoney) {
|
| | | this.leftMoney = leftMoney;
|
| | | }
|
| | |
|
| | | public Long getSourceId() {
|
| | | return sourceId;
|
| | | }
|
| | |
|
| | | public void setSourceId(Long sourceId) {
|
| | | this.sourceId = sourceId;
|
| | | }
|
| | |
|
| | | public String getBeiZhu() {
|
| | | return beiZhu;
|
| | | }
|
| | |
|
| | | public void setBeiZhu(String beiZhu) {
|
| | | this.beiZhu = beiZhu;
|
| | | }
|
| | |
|
| | | 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.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 订单补贴欠账还款记录
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_ec_invite_order_subsidy_debt_repay_history")
|
| | | public class InviteOrderSubsidyDebtRepayHistory {
|
| | | @Column(name = "rh_id")
|
| | | private Long id;
|
| | | @Column(name = "rh_debt_id")
|
| | | private InviteOrderSubsidyDebt debt;
|
| | | @Column(name = "rh_money")
|
| | | private BigDecimal money;
|
| | | @Column(name = "rh_uid")
|
| | | private Long uid;
|
| | | @Column(name = "rh_beizhu")
|
| | | private String beiZhu;
|
| | | @Column(name = "rh_create_time")
|
| | | private Date createTime;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public InviteOrderSubsidyDebt getDebt() {
|
| | | return debt;
|
| | | }
|
| | |
|
| | | public void setDebt(InviteOrderSubsidyDebt debt) {
|
| | | this.debt = debt;
|
| | | }
|
| | |
|
| | | public BigDecimal getMoney() {
|
| | | return money;
|
| | | }
|
| | |
|
| | | public void setMoney(BigDecimal money) {
|
| | | this.money = money;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public String getBeiZhu() {
|
| | | return beiZhu;
|
| | | }
|
| | |
|
| | | public void setBeiZhu(String beiZhu) {
|
| | | this.beiZhu = beiZhu;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | public enum UserMoneyDetailTypeEnum {
|
| | | share("分享奖金", "http://img.flqapp.com/resource/money_detail/icon_share.png", ""), invite("邀请奖金", "http://img.flqapp.com/resource/money_detail/icon_invite.png", ""), inviteAndShare("奖金收入", "http://img.flqapp.com/resource/money_detail/icon_share.png", ""), fanli("返利到账", "http://img.flqapp.com/resource/money_detail/icon_fanli.png",
|
| | | ""), fanliWeiQuan("返利扣除", "http://img.flqapp.com/resource/money_detail/icon_fanli.png", "http://apph5.yeshitv.com/apppage/flq_whyMoneyDel.html"), inviteWeiQuan("邀请奖金扣除", "http://img.flqapp.com/resource/money_detail/icon_invite.png", "http://apph5.yeshitv.com/apppage/flq_whyMoneyDel.html"), shareWeiQuan("分享奖金扣除", "http://img.flqapp.com/resource/money_detail/icon_share.png",
|
| | | "http://apph5.yeshitv.com/apppage/flq_whyMoneyDel.html"), weiQuan("售后订单扣款", "http://img.flqapp.com/resource/money_detail/icon_fanli.png", "http://apph5.yeshitv.com/apppage/flq_whyMoneyDel.html"), systemEqualize("系统补齐", "http://img.flqapp.com/resource/money_detail/icon_system.png", ""), scoreConvert("金币兑换", "http://img.flqapp.com/resource/money_detail/icon_score.png",
|
| | | ""), fanliWeiQuan("返利扣除", "http://img.flqapp.com/resource/money_detail/icon_fanli.png", "http://apph5.yeshitv.com/AppPage/1.8.0/all_help_content.html?id=214"), inviteWeiQuan("邀请奖金扣除", "http://img.flqapp.com/resource/money_detail/icon_invite.png", "http://apph5.yeshitv.com/AppPage/1.8.0/all_help_content.html?id=214"), shareWeiQuan("分享奖金扣除", "http://img.flqapp.com/resource/money_detail/icon_share.png",
|
| | | "http://apph5.yeshitv.com/AppPage/1.8.0/all_help_content.html?id=214"), weiQuan("售后订单扣款", "http://img.flqapp.com/resource/money_detail/icon_fanli.png", "http://apph5.yeshitv.com/AppPage/1.8.0/all_help_content.html?id=214"), systemEqualize("系统补齐", "http://img.flqapp.com/resource/money_detail/icon_system.png", ""), scoreConvert("金币兑换", "http://img.flqapp.com/resource/money_detail/icon_score.png",
|
| | | ""), hongbao("官方红包", "http://img.flqapp.com/resource/money_detail/icon_hongbao.png", ""), hongbaoDeduct("红包退款", "http://img.flqapp.com/resource/money_detail/icon_hongbao.png",
|
| | | ""), buyScore("购买积分", "http://img.flqapp.com/resource/money_detail/icon_score.png", ""), extract("提现", "http://img.flqapp.com/resource/money_detail/icon_extract.png",
|
| | | ""), extractVerify("提现验证", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""), extractReject("提现被拒", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""),orderReward("返利奖励金","http://img.flqapp.com/resource/money_detail/icon_order_reward.png",""),repeatStatistic("重复统计返利/奖金扣除","http://img.flqapp.com/resource/money_detail/icon_fanli.png",""), |
| | | elmeFanli("饿了么返利到账","http://img.flqapp.com/resource/money_detail/icon_fanli.png",""),
|
| | | redPackExchange("红包提现到余额", "http://img.flqapp.com/resource/money_detail/icon_score.png",""),
|
| | | extractAutoWX("自动提现", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""), extractAutoWXRefund("自动提现失败", "http://img.flqapp.com/resource/money_detail/icon_extract.png", "");
|
| | | extractAutoWX("自动提现", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""),
|
| | | extractAutoWXRefund("自动提现失败", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""),
|
| | | subsidy("额外补贴","","");
|
| | | |
| | |
|
| | | private final String desc;
|
| | |
| | | private Date updateTime;
|
| | |
|
| | | private Integer state;//老版明细适用该字段
|
| | | |
| | | @Column(name = "umd_show")
|
| | | private Boolean show;//是否显示
|
| | |
|
| | | public Boolean getShow() {
|
| | | return show;
|
| | | }
|
| | |
|
| | | public void setShow(Boolean show) {
|
| | | this.show = show;
|
| | | }
|
| | |
|
| | | public Integer getState() {
|
| | | return state;
|
New file |
| | |
| | | package com.yeshi.fanli.entity.mq;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 消息发送失败的缓存表
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_ec_mq_unsend_info")
|
| | | public class MQUnSendInfo {
|
| | | @Column(name = "mui_id")
|
| | | private Long id;
|
| | | @Column(name = "mui_topic")
|
| | | private String topic;
|
| | | @Column(name = "mui_tag")
|
| | | private String tag;
|
| | | @Column(name = "mui_body")
|
| | | private String body;
|
| | | @Column(name = "mui_key")
|
| | | private String key;
|
| | | @Column(name = "mui_deliver_time")
|
| | | private Date deliverTime;// 延时
|
| | | @Column(name = "mui_last_send_time")
|
| | | private Date lastSendTime;// 发送时间
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public String getTopic() {
|
| | | return topic;
|
| | | }
|
| | |
|
| | | public void setTopic(String topic) {
|
| | | this.topic = topic;
|
| | | }
|
| | |
|
| | | public String getTag() {
|
| | | return tag;
|
| | | }
|
| | |
|
| | | public void setTag(String tag) {
|
| | | this.tag = tag;
|
| | | }
|
| | |
|
| | | public String getBody() {
|
| | | return body;
|
| | | }
|
| | |
|
| | | public void setBody(String body) {
|
| | | this.body = body;
|
| | | }
|
| | |
|
| | | public String getKey() {
|
| | | return key;
|
| | | }
|
| | |
|
| | | public void setKey(String key) {
|
| | | this.key = key;
|
| | | }
|
| | |
|
| | | public Date getDeliverTime() {
|
| | | return deliverTime;
|
| | | }
|
| | |
|
| | | public void setDeliverTime(Date deliverTime) {
|
| | | this.deliverTime = deliverTime;
|
| | | }
|
| | |
|
| | | public Date getLastSendTime() {
|
| | | return lastSendTime;
|
| | | }
|
| | |
|
| | | public void setLastSendTime(Date lastSendTime) {
|
| | | this.lastSendTime = lastSendTime;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.order;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | @Table("yeshi_ec_hongbao_v2_settle_temp")
|
| | | public class HongBaoV2SettleTemp {
|
| | | @Column(name = "id")
|
| | | private Long id;
|
| | | @Column(name = "task_key")
|
| | | private String taskKey;
|
| | | @Column(name = "hongbao_id")
|
| | | private Long hongBaoId;
|
| | | @Column(name = "create_time")
|
| | | private Date createTime;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public String getTaskKey() {
|
| | | return taskKey;
|
| | | }
|
| | |
|
| | | public void setTaskKey(String taskKey) {
|
| | | this.taskKey = taskKey;
|
| | | }
|
| | |
|
| | | public Long getHongBaoId() {
|
| | | return hongBaoId;
|
| | | }
|
| | |
|
| | | public void setHongBaoId(Long hongBaoId) {
|
| | | this.hongBaoId = hongBaoId;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | | }
|
| | |
| | | private Long uid;
|
| | | @Column(name = "os_money")
|
| | | private BigDecimal money;
|
| | | @Column(name = "os_original_money")
|
| | | private BigDecimal originalMoney;// 原返利
|
| | | @Column(name = "os_order_no")
|
| | | private String orderNo;
|
| | | @Column(name = "os_source_type")
|
| | |
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | public BigDecimal getOriginalMoney() {
|
| | | return originalMoney;
|
| | | }
|
| | |
|
| | | public void setOriginalMoney(BigDecimal originalMoney) {
|
| | | this.originalMoney = originalMoney;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.money;
|
| | |
|
| | | import com.yeshi.fanli.exception.BaseException;
|
| | |
|
| | | public class InviteOrderSubsidyDebtException extends BaseException {
|
| | |
|
| | | /**
|
| | | * |
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public InviteOrderSubsidyDebtException(int code, String msg) {
|
| | | super(code, msg);
|
| | | }
|
| | |
|
| | | public InviteOrderSubsidyDebtException() {
|
| | | super();
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.money;
|
| | |
|
| | | import com.yeshi.fanli.exception.BaseException;
|
| | |
|
| | | public class OrderMoneySettleException extends BaseException {
|
| | |
|
| | | /**
|
| | | * |
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public OrderMoneySettleException(int code, String msg) {
|
| | | super(code, msg);
|
| | | }
|
| | |
|
| | | public OrderMoneySettleException() {
|
| | | super();
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.mq;
|
| | |
|
| | | import com.yeshi.fanli.exception.BaseException;
|
| | |
|
| | | public class MQUnSendInfoException extends BaseException {
|
| | | |
| | | private static final long serialVersionUID = 1L;
|
| | | |
| | | public MQUnSendInfoException(int code, String msg) {
|
| | | super(code, msg);
|
| | | }
|
| | |
|
| | | public MQUnSendInfoException() {
|
| | | super();
|
| | | }
|
| | | }
|
| | |
| | | for (int i = 0; i < 24; i++) {
|
| | | Date da = new Date(startTime.getTime() + 1000 * 60 * 60L * i);
|
| | | if (da.getTime() > now.getTime())
|
| | | return;
|
| | | break;
|
| | | List<JDOrder> tempOrderList = getHourOrder(da);
|
| | | if (tempOrderList != null && tempOrderList.size() > 0)
|
| | | orderList.addAll(tempOrderList);
|
| | |
| | | private static Logger requestLogger = Logger.getLogger("requestLog");
|
| | |
|
| | | private static Logger requestTimeLogger = Logger.getLogger("requestTimeLog");
|
| | | |
| | |
|
| | | private static Logger jobLogger = Logger.getLogger("jobLog");
|
| | |
|
| | | private static Logger mqLogger = Logger.getLogger("mqLog");
|
| | |
|
| | | public static void userInfo(Object obj) {
|
| | | userLogger.info(obj);
|
| | |
| | | public static void shareGoods(Object obj) {
|
| | | shareGoodsLogger.info(obj);
|
| | | }
|
| | | |
| | |
|
| | | public static void job(Object obj) {
|
| | | jobLogger.info(obj);
|
| | | }
|
| | |
|
| | | public static void mqError(String errorMsg, String topic, String tag, Object data) {
|
| | | String error = errorMsg + "\ntopic:" + topic + "\ntag:" + tag + "\nbody:" + data;
|
| | | mqLogger.error(error);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 登录信息
|
| | | *
|
| | |
| | | <result column="hb_get_time" property="getTime" jdbcType="TIMESTAMP" />
|
| | | <result column="hb_create_time" property="createTime" jdbcType="TIMESTAMP" />
|
| | | <result column="hb_update_time" property="updateTime" jdbcType="TIMESTAMP" />
|
| | |
|
| | | <result column="hb_order_type" property="orderType" jdbcType="INTEGER" />
|
| | | <association property="userInfo" column="hb_uid"
|
| | | javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
|
| | | <id column="hb_uid" property="id" jdbcType="BIGINT" />
|
| | |
| | | <result column="hb_update_time" property="updateTime" jdbcType="TIMESTAMP" />
|
| | |
|
| | | <result column="orderId" property="orderId" jdbcType="VARCHAR" />
|
| | | |
| | | <result column="hb_order_type" property="orderType" jdbcType="INTEGER" />
|
| | |
|
| | | <result column="payMoney" property="payMoney" jdbcType="DECIMAL" />
|
| | |
|
| | |
| | | </resultMap>
|
| | |
|
| | |
|
| | | <sql id="Base_Column_List">hb_id,hb_uid,hb_urank,hb_pid,hb_money,hb_type,hb_state,hb_version,hb_beizhu,hb_pre_get_time,hb_get_time,hb_create_time,hb_update_time
|
| | | <sql id="Base_Column_List">hb_id,hb_uid,hb_urank,hb_pid,hb_money,hb_type,hb_state,hb_version,hb_beizhu,hb_pre_get_time,hb_get_time,hb_create_time,hb_update_time,hb_order_type
|
| | | </sql>
|
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
| | | parameterType="java.lang.Long">
|
| | |
| | | <include refid="Base_Column_List" />
|
| | | from yeshi_ec_hongbao_v2 where hb_pid = #{0}
|
| | | </select>
|
| | |
|
| | |
|
| | | <select id="listChildrenByIds" resultMap="BaseResultMap">
|
| | | select
|
| | | <include refid="Base_Column_List" />
|
| | | from yeshi_ec_hongbao_v2 where
|
| | | <foreach collection="idList" item="id" open="(" separator=" or "
|
| | | close=")">
|
| | | hb_pid=#{id}
|
| | | </foreach>
|
| | | </select>
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | <select id="listCanBalanceHongBaoByType" resultMap="BaseResultMap">
|
| | |
| | | <if test="uid!=null">
|
| | | and hb_uid=#{uid}
|
| | | </if>
|
| | | |
| | | <if test="orderType!=null">
|
| | | and hb_order_type=#{orderType}
|
| | | </if>
|
| | |
|
| | | <foreach collection="types" item="type" open=" and ("
|
| | | separator=" or " close=")">
|
| | |
| | | count(hb_id)
|
| | | from yeshi_ec_hongbao_v2 where hb_uid=#{uid} and
|
| | | `hb_version`=2
|
| | | |
| | | <if test="orderType!=null">
|
| | | and hb_order_type=#{orderType}
|
| | | </if>
|
| | |
|
| | | <foreach collection="types" item="type" open=" and ("
|
| | | separator=" or " close=")">
|
| | |
| | | <select id="listBySourceTypeAndTradeIdListAndUid" resultMap="BaseResultMap">
|
| | | SELECT a.* FROM
|
| | | (
|
| | | SELECT * FROM yeshi_ec_hongbao_v2 v WHERE v.`hb_uid`=#{uid}
|
| | | ) a |
| | | SELECT * FROM yeshi_ec_hongbao_v2 v WHERE
|
| | | v.`hb_uid`=#{uid}
|
| | | ) a
|
| | | LEFT JOIN
|
| | | (
|
| | | SELECT ho.`ho_hongbao_id` AS hbId FROM yeshi_ec_hongbao_order ho LEFT JOIN
|
| | | yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE
|
| | | SELECT ho.`ho_hongbao_id` AS hbId FROM
|
| | | yeshi_ec_hongbao_order ho
|
| | | LEFT JOIN
|
| | | yeshi_ec_common_order co ON
|
| | | co.`co_id`=ho.`ho_order_id` WHERE
|
| | | co.`co_source_type`=#{sourceType}
|
| | | <if test="tradeIdList!=null">
|
| | | <foreach collection="tradeIdList" open=" and (" close=")"
|
| | |
| | | b
|
| | | ON a.hb_id=b.hbId OR a.hb_pid=b.hbId WHERE b.hbId >0
|
| | | </select>
|
| | | |
| | |
|
| | | <select id="listByStateAndTypeAndUid" resultMap="BaseResultMap">
|
| | | |
| | |
|
| | | SELECT * FROM yeshi_ec_hongbao_v2 v where v.hb_uid=#{uid}
|
| | | <if test="stateList!=null">
|
| | | <foreach collection="stateList" open=" and (" item="state" separator=" or " close=")">
|
| | | <foreach collection="stateList" open=" and (" item="state"
|
| | | separator=" or " close=")">
|
| | | hb_state=#{state}
|
| | | </foreach>
|
| | | </if>
|
| | | |
| | |
|
| | | <if test="typeList!=null">
|
| | | <foreach collection="typeList" open=" and (" item="type" separator=" or " close=")">
|
| | | <foreach collection="typeList" open=" and (" item="type"
|
| | | separator=" or " close=")">
|
| | | hb_type=#{type}
|
| | | </foreach>
|
| | | </if>
|
| | | order by hb_create_time asc,hb_id asc
|
| | | limit #{start},#{count}
|
| | | </select>
|
| | | |
| | | |
| | |
|
| | | <select id="listByIds" resultMap="BaseResultMap">
|
| | | SELECT * FROM yeshi_ec_hongbao_v2 v where
|
| | | <foreach collection="idList" item="id" separator=" or " open="("
|
| | | close=")">
|
| | | v.hb_id=#{id}
|
| | | </foreach>
|
| | | </select>
|
| | |
|
| | |
|
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
| | | yeshi_ec_hongbao_v2 where hb_id = #{id,jdbcType=BIGINT}
|
| | | </delete>
|
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2"
|
| | | useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_hongbao_v2
|
| | | (hb_id,hb_uid,hb_urank,hb_pid,hb_money,hb_type,hb_state,hb_version,hb_beizhu,hb_pre_get_time,hb_get_time,hb_create_time,hb_update_time)
|
| | | (hb_id,hb_uid,hb_urank,hb_pid,hb_money,hb_type,hb_state,hb_version,hb_beizhu,hb_pre_get_time,hb_get_time,hb_create_time,hb_update_time,hb_order_type)
|
| | | values
|
| | | (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{urank,jdbcType=INTEGER},#{parent.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{version,jdbcType=INTEGER},#{beizhu,jdbcType=VARCHAR},#{preGetTime,jdbcType=TIMESTAMP},#{getTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
|
| | | (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{urank,jdbcType=INTEGER},#{parent.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{version,jdbcType=INTEGER},#{beizhu,jdbcType=VARCHAR},#{preGetTime,jdbcType=TIMESTAMP},#{getTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{orderType,jdbcType=INTEGER})
|
| | | </insert>
|
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2"
|
| | | useGeneratedKeys="true" keyProperty="id">
|
| | |
| | | <if test="getTime != null">hb_get_time,</if>
|
| | | <if test="createTime != null">hb_create_time,</if>
|
| | | <if test="updateTime != null">hb_update_time,</if>
|
| | | <if test="orderType != null">hb_order_type,</if>
|
| | | </trim>
|
| | | values
|
| | | <trim prefix="(" suffix=")" suffixOverrides=",">
|
| | |
| | | <if test="getTime != null">#{getTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="orderType != null">#{orderType,jdbcType=INTEGER},</if>
|
| | | </trim>
|
| | | </insert>
|
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2">update
|
| | |
| | | #{preGetTime,jdbcType=TIMESTAMP},hb_get_time =
|
| | | #{getTime,jdbcType=TIMESTAMP},hb_create_time =
|
| | | #{createTime,jdbcType=TIMESTAMP},hb_update_time =
|
| | | #{updateTime,jdbcType=TIMESTAMP} where hb_id = #{id,jdbcType=BIGINT}
|
| | | #{updateTime,jdbcType=TIMESTAMP},hb_order_type =
|
| | | #{orderType,jdbcType=INTEGER} where hb_id = #{id,jdbcType=BIGINT}
|
| | | </update>
|
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2">
|
| | | update yeshi_ec_hongbao_v2
|
| | |
| | | <if test="getTime != null">hb_get_time=#{getTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="createTime != null">hb_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="updateTime != null">hb_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="orderType != null">hb_order_type=#{orderType,jdbcType=INTEGER},</if>
|
| | | </set>
|
| | | where hb_id = #{id,jdbcType=BIGINT}
|
| | | </update>
|
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.hongbao.HongBaoV2SettleTempMapper"> |
| | | <resultMap id="BaseResultMap" |
| | | type="com.yeshi.fanli.entity.order.HongBaoV2SettleTemp"> |
| | | <id column="id" property="id" jdbcType="BIGINT" /> |
| | | <result column="task_key" property="taskKey" jdbcType="VARCHAR" /> |
| | | <result column="hongbao_id" property="hongBaoId" jdbcType="BIGINT" /> |
| | | <result column="create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">id,task_key,hongbao_id,create_time</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_hongbao_v2_settle_temp where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <select id="listByKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.String"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_hongbao_v2_settle_temp where task_key = #{0} |
| | | </select> |
| | | |
| | | <select id="countByKey" resultType="java.lang.Long" |
| | | parameterType="java.lang.String"> |
| | | select |
| | | count(*) |
| | | from yeshi_ec_hongbao_v2_settle_temp where task_key = #{0} |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_hongbao_v2_settle_temp where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.order.HongBaoV2SettleTemp" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_hongbao_v2_settle_temp (id,task_key,hongbao_id,create_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{taskKey,jdbcType=VARCHAR},#{hongBaoId,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.order.HongBaoV2SettleTemp" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_hongbao_v2_settle_temp |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">id,</if> |
| | | <if test="taskKey != null">task_key,</if> |
| | | <if test="hongBaoId != null">hongbao_id,</if> |
| | | <if test="createTime != null">create_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="taskKey != null">#{taskKey,jdbcType=VARCHAR},</if> |
| | | <if test="hongBaoId != null">#{hongBaoId,jdbcType=BIGINT},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.order.HongBaoV2SettleTemp">update |
| | | yeshi_ec_hongbao_v2_settle_temp set task_key = |
| | | #{taskKey,jdbcType=VARCHAR},hongbao_id = |
| | | #{hongBaoId,jdbcType=BIGINT},create_time = |
| | | #{createTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.HongBaoV2SettleTemp"> |
| | | update yeshi_ec_hongbao_v2_settle_temp |
| | | <set> |
| | | <if test="taskKey != null">task_key=#{taskKey,jdbcType=VARCHAR},</if> |
| | | <if test="hongBaoId != null">hongbao_id=#{hongBaoId,jdbcType=BIGINT},</if> |
| | | <if test="createTime != null">create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </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.money.InviteOrderSubsidyDebtMapper"> |
| | | <resultMap id="BaseResultMap" |
| | | type="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt"> |
| | | <id column="sd_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="sd_uid" property="uid" jdbcType="BIGINT" /> |
| | | <result column="sd_origin_money" property="originMoney" |
| | | jdbcType="DECIMAL" /> |
| | | <result column="sd_left_money" property="leftMoney" jdbcType="DECIMAL" /> |
| | | <result column="sd_source_id" property="sourceId" jdbcType="BIGINT" /> |
| | | <result column="sd_beizhu" property="beiZhu" jdbcType="VARCHAR" /> |
| | | <result column="sd_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="sd_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">sd_id,sd_uid,sd_origin_money,sd_left_money,sd_source_id,sd_beizhu,sd_create_time,sd_update_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_invite_order_subsidy_debt where sd_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_invite_order_subsidy_debt where sd_id = |
| | | #{0} for update |
| | | </select> |
| | | |
| | | |
| | | <select id="listByLeftMoneyAndUid" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_invite_order_subsidy_debt where sd_uid = |
| | | #{uid} |
| | | <if test="minMoney!=null"> |
| | | and sd_left_money>=#{minMoney} |
| | | </if> |
| | | |
| | | <if test="maxMoney!=null"> |
| | | and #{maxMoney}>sd_left_money |
| | | </if> |
| | | limit #{start},#{count} |
| | | </select> |
| | | |
| | | <select id="countByLeftMoneyAndUid" resultType="java.lang.Long"> |
| | | select |
| | | count(*) |
| | | from yeshi_ec_invite_order_subsidy_debt where sd_uid = |
| | | #{uid} |
| | | <if test="minMoney!=null"> |
| | | and sd_left_money>=#{minMoney} |
| | | </if> |
| | | |
| | | <if test="maxMoney!=null"> |
| | | and #{maxMoney}>sd_left_money |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <select id="sumLeftMoneyByUid" resultType="java.math.BigDecimal"> |
| | | select |
| | | sum(sd_left_money) |
| | | from yeshi_ec_invite_order_subsidy_debt where sd_uid = |
| | | #{0} |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_invite_order_subsidy_debt where sd_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_invite_order_subsidy_debt |
| | | (sd_id,sd_uid,sd_origin_money,sd_left_money,sd_source_id,sd_beizhu,sd_create_time,sd_update_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{originMoney,jdbcType=DECIMAL},#{leftMoney,jdbcType=DECIMAL},#{sourceId,jdbcType=BIGINT},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_invite_order_subsidy_debt |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">sd_id,</if> |
| | | <if test="uid != null">sd_uid,</if> |
| | | <if test="originMoney != null">sd_origin_money,</if> |
| | | <if test="leftMoney != null">sd_left_money,</if> |
| | | <if test="sourceId != null">sd_source_id,</if> |
| | | <if test="beiZhu != null">sd_beizhu,</if> |
| | | <if test="createTime != null">sd_create_time,</if> |
| | | <if test="updateTime != null">sd_update_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="originMoney != null">#{originMoney,jdbcType=DECIMAL},</if> |
| | | <if test="leftMoney != null">#{leftMoney,jdbcType=DECIMAL},</if> |
| | | <if test="sourceId != null">#{sourceId,jdbcType=BIGINT},</if> |
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</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.money.InviteOrderSubsidyDebt">update |
| | | yeshi_ec_invite_order_subsidy_debt set sd_uid = |
| | | #{uid,jdbcType=BIGINT},sd_origin_money = |
| | | #{originMoney,jdbcType=DECIMAL},sd_left_money = |
| | | #{leftMoney,jdbcType=DECIMAL},sd_source_id = |
| | | #{sourceId,jdbcType=BIGINT},sd_beizhu = |
| | | #{beiZhu,jdbcType=VARCHAR},sd_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},sd_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} where sd_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt"> |
| | | update yeshi_ec_invite_order_subsidy_debt |
| | | <set> |
| | | <if test="uid != null">sd_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="originMoney != null">sd_origin_money=#{originMoney,jdbcType=DECIMAL},</if> |
| | | <if test="leftMoney != null">sd_left_money=#{leftMoney,jdbcType=DECIMAL},</if> |
| | | <if test="sourceId != null">sd_source_id=#{sourceId,jdbcType=BIGINT},</if> |
| | | <if test="beiZhu != null">sd_beizhu=#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">sd_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">sd_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | | where sd_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </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.money.InviteOrderSubsidyDebtRepayHistoryMapper"> |
| | | <resultMap id="BaseResultMap" |
| | | type="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebtRepayHistory"> |
| | | <id column="rh_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="rh_money" property="money" jdbcType="DECIMAL" /> |
| | | <result column="rh_uid" property="uid" jdbcType="BIGINT" /> |
| | | <result column="rh_beizhu" property="beiZhu" jdbcType="VARCHAR" /> |
| | | <result column="rh_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <association property="debt" column="rh_debt_id" |
| | | javaType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt"> |
| | | <id column="rh_debt_id" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">rh_id,rh_debt_id,rh_money,rh_uid,rh_beizhu,rh_create_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_invite_order_subsidy_debt_repay_history where rh_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_invite_order_subsidy_debt_repay_history where rh_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" |
| | | parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebtRepayHistory" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_invite_order_subsidy_debt_repay_history |
| | | (rh_id,rh_debt_id,rh_money,rh_uid,rh_beizhu,rh_create_time) values |
| | | (#{id,jdbcType=BIGINT},#{debt.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{uid,jdbcType=BIGINT},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" |
| | | parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebtRepayHistory" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_invite_order_subsidy_debt_repay_history |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">rh_id,</if> |
| | | <if test="debt != null">rh_debt_id,</if> |
| | | <if test="money != null">rh_money,</if> |
| | | <if test="uid != null">rh_uid,</if> |
| | | <if test="beiZhu != null">rh_beizhu,</if> |
| | | <if test="createTime != null">rh_create_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="debt != null">#{debt.id,jdbcType=BIGINT},</if> |
| | | <if test="money != null">#{money,jdbcType=DECIMAL},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" |
| | | parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebtRepayHistory">update yeshi_ec_invite_order_subsidy_debt_repay_history |
| | | set rh_debt_id = #{debt.id,jdbcType=BIGINT},rh_money = |
| | | #{money,jdbcType=DECIMAL},rh_uid = #{uid,jdbcType=BIGINT},rh_beizhu = |
| | | #{beiZhu,jdbcType=VARCHAR},rh_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP} where rh_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" |
| | | parameterType="com.yeshi.fanli.entity.money.InviteOrderSubsidyDebtRepayHistory"> |
| | | update yeshi_ec_invite_order_subsidy_debt_repay_history |
| | | <set> |
| | | <if test="debt != null">rh_debt_id=#{debt.id,jdbcType=BIGINT},</if> |
| | | <if test="money != null">rh_money=#{money,jdbcType=DECIMAL},</if> |
| | | <if test="uid != null">rh_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="beiZhu != null">rh_beizhu=#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">rh_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | | where rh_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
| | |
| | | <?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.money.UserMoneyDetailMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.money.UserMoneyDetail"> |
| | | <id column="umd_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="umd_money" property="money" jdbcType="DECIMAL" /> |
| | | <result column="umd_type" property="type" |
| | | typeHandler="com.yeshi.fanli.util.mybatishandler.UserMoneyDetailTypeEnumHandler" /> |
| | | <result column="umd_title" property="title" jdbcType="VARCHAR" /> |
| | | <result column="umd_sub_title" property="subTitle" jdbcType="VARCHAR" /> |
| | | <result column="umd_desc_info" property="descInfo" jdbcType="VARCHAR" /> |
| | | <result column="umd_source_identify_id" property="sourceIdentifyId" |
| | | jdbcType="BIGINT" /> |
| | | <result column="umd_identify_code" property="identifyCode" |
| | | jdbcType="VARCHAR" /> |
| | | <result column="umd_beizhu" property="beiZhu" jdbcType="VARCHAR" /> |
| | | <result column="umd_createtime" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="umd_updatetime" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | <!-- 老版明细适用该字段 --> |
| | | <result column="state" property="state" jdbcType="INTEGER" /> |
| | | <result column="umd_order_type" property="orderType" jdbcType="INTEGER" /> |
| | | <association property="userInfo" column="umd_uid" |
| | | javaType="com.yeshi.fanli.entity.bus.user.UserInfo"> |
| | | <id column="umd_uid" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | |
| | | </resultMap> |
| | | <resultMap id="UserMonthMoneyMap" type="com.yeshi.fanli.vo.money.UserMonthMoneyVO"> |
| | | <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">umd_id,umd_uid,umd_money,umd_type,umd_title,umd_sub_title,umd_desc_info,umd_source_identify_id,umd_identify_code,umd_beizhu,umd_createtime,umd_updatetime,umd_order_type |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_user_money_detail where umd_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <select id="selectByUidWithIndexId" resultMap="BaseResultMap"> |
| | | SELECT |
| | | <include refid="Base_Column_List" /> |
| | | FROM yeshi_ec_user_money_detail d WHERE d.`umd_createtime` <![CDATA[ |
| | | <= |
| | | ]]> |
| | | (SELECT d.`umd_createtime` FROM yeshi_ec_user_money_detail d WHERE |
| | | d.`umd_id`=#{id}) and d.umd_uid=#{uid} order by d.`umd_createtime` |
| | | desc,d.umd_id desc limit #{count} |
| | | </select> |
| | | <select id="selectCountByUid" resultType="java.lang.Long" |
| | | parameterType="java.lang.Long">SELECT count(umd_id) FROM yeshi_ec_user_money_detail |
| | | where umd_uid=#{uid}</select> |
| | | <select id="selectByMaxCreateTime" resultMap="BaseResultMap"> |
| | | SELECT |
| | | <include refid="Base_Column_List" /> |
| | | FROM yeshi_ec_user_money_detail d WHERE d.umd_uid=#{uid} and |
| | | d.`umd_createtime`<![CDATA[ |
| | | <= |
| | | ]]> |
| | | #{date} order by d.`umd_createtime` desc,d.umd_id desc limit #{count} |
| | | </select> |
| | | <select id="selectCountByUidAndMaxCreateTime" resultType="java.lang.Long">SELECT |
| | | count(umd_id) FROM yeshi_ec_user_money_detail where umd_uid=#{uid} and |
| | | `umd_createtime`<![CDATA[ |
| | | <= |
| | | ]]> |
| | | #{date} |
| | | </select> |
| | | <select id="selectMonthCountByUid" resultType="java.lang.Integer">SELECT |
| | | COUNT(*) FROM (SELECT * FROM yeshi_ec_user_money_detail d WHERE |
| | | d.`umd_uid`=#{uid} and d.`umd_createtime` <![CDATA[<=]]> |
| | | #{date} group by DATE_FORMAT(d.`umd_createtime`,'%y-%m')) a |
| | | </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.`umd_createtime`,'%Y-%m') AS `time`,SUM(d.`umd_money`) AS money |
| | | FROM `yeshi_ec_user_money_detail` d WHERE d.`umd_uid`=#{uid} AND |
| | | d.`umd_money`>=0 AND DATE_FORMAT( |
| | | d.`umd_createtime`,'%Y-%m')=#{item} GROUP BY DATE_FORMAT( |
| | | d.`umd_createtime`,'%Y-%m') ) a on a.time=c.time LEFT JOIN ( SELECT |
| | | DATE_FORMAT( d.`umd_createtime`,'%Y-%m') AS |
| | | `time`,SUM(d.`umd_money`) AS money FROM `yeshi_ec_user_money_detail` |
| | | d WHERE d.`umd_uid`=#{uid} AND d.`umd_money`<![CDATA[<0]]> |
| | | AND DATE_FORMAT( d.`umd_createtime`,'%Y-%m')=#{item} GROUP BY |
| | | DATE_FORMAT( d.`umd_createtime`,'%Y-%m') ) b ON c.time=b.time |
| | | </trim> |
| | | </foreach> |
| | | </select> |
| | | <select id="selectByUidWithState" resultMap="BaseResultMap">SELECT a.* FROM |
| | | ((SELECT d.*,-1 AS state FROM `yeshi_ec_user_money_detail` d WHERE |
| | | d.`umd_uid`=#{uid} AND (d.`umd_type`!='extract' AND |
| | | d.`umd_type`!='extractReject') ) UNION ALL( SELECT d.*,-1 AS state |
| | | FROM `yeshi_ec_user_money_detail` d LEFT JOIN `yeshi_ec_extract` e ON |
| | | e.`id`=d.umd_source_identify_id WHERE d.`umd_uid`=#{uid} AND |
| | | d.umd_type='extractReject' ) UNION ALL( SELECT d.*,e.state FROM |
| | | `yeshi_ec_user_money_detail` d LEFT JOIN `yeshi_ec_extract` e ON |
| | | e.`id`=d.`umd_source_identify_id` WHERE d.`umd_uid`=#{uid} AND |
| | | d.umd_type='extract' )) a ORDER BY a.umd_createtime DESC LIMIT |
| | | #{start},#{count}</select> |
| | | <select id="selectCountByUidWithState" resultType="java.lang.Long">SELECT |
| | | count(*) FROM ((SELECT d.*,-1 AS state FROM |
| | | `yeshi_ec_user_money_detail` d WHERE d.`umd_uid`=#{uid} AND |
| | | (d.`umd_type`!='extract' AND d.`umd_type`!='extractReject') ) UNION |
| | | ALL( SELECT d.*,-1 AS state FROM `yeshi_ec_user_money_detail` d LEFT |
| | | JOIN `yeshi_ec_extract` e ON e.`id`=d.umd_source_identify_id WHERE |
| | | d.`umd_uid`=#{uid} AND d.umd_type='extractReject' ) UNION ALL( SELECT |
| | | d.*,e.state FROM `yeshi_ec_user_money_detail` d LEFT JOIN |
| | | `yeshi_ec_extract` e ON e.`id`=d.`umd_source_identify_id` WHERE |
| | | d.`umd_uid`=#{uid} AND d.umd_type='extract' )) a</select> |
| | | <select id="getTotalMoneyByTypeAndUidWithDate" resultType="java.math.BigDecimal">select |
| | | sum(umd_money) from yeshi_ec_user_money_detail where umd_uid=#{uid} |
| | | and umd_createtime>=#{minDate} and umd_createtime<![CDATA[<]]>#{maxDate} |
| | | <foreach collection="typeList" item="item" open=" and (" |
| | | separator=" or " close=")">umd_type=#{item}</foreach> |
| | | </select> |
| | | <select id="selectByTypeAndUidAndIdentifyCode" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_user_money_detail where umd_uid=#{uid} and |
| | | umd_type=#{type} and umd_source_identify_id=#{sourceIdentifyId} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_user_money_detail where umd_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_user_money_detail |
| | | (umd_id,umd_uid,umd_money,umd_type,umd_title,umd_sub_title,umd_desc_info,umd_source_identify_id,umd_identify_code,umd_beizhu,umd_createtime,umd_updatetime,umd_order_type) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=VARCHAR},#{title,jdbcType=VARCHAR},#{subTitle,jdbcType=VARCHAR},#{descInfo,jdbcType=VARCHAR},#{sourceIdentifyId,jdbcType=BIGINT},#{identifyCode,jdbcType=VARCHAR},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{orderType,jdbcType=INTEGER}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_user_money_detail |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">umd_id,</if> |
| | | <if test="userInfo != null">umd_uid,</if> |
| | | <if test="money != null">umd_money,</if> |
| | | <if test="type != null">umd_type,</if> |
| | | <if test="title != null">umd_title,</if> |
| | | <if test="subTitle != null">umd_sub_title,</if> |
| | | <if test="descInfo != null">umd_desc_info,</if> |
| | | <if test="sourceIdentifyId != null">umd_source_identify_id,</if> |
| | | <if test="identifyCode != null">umd_identify_code,</if> |
| | | <if test="beiZhu != null">umd_beizhu,</if> |
| | | <if test="createTime != null">umd_createtime,</if> |
| | | <if test="updateTime != null">umd_updatetime,</if> |
| | | <if test="orderType != null">umd_order_type,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT},</if> |
| | | <if test="money != null">#{money,jdbcType=DECIMAL},</if> |
| | | <if test="type != null">#{type,jdbcType=VARCHAR},</if> |
| | | <if test="title != null">#{title,jdbcType=VARCHAR},</if> |
| | | <if test="subTitle != null">#{subTitle,jdbcType=VARCHAR},</if> |
| | | <if test="descInfo != null">#{descInfo,jdbcType=VARCHAR},</if> |
| | | <if test="sourceIdentifyId != null">#{sourceIdentifyId,jdbcType=BIGINT},</if> |
| | | <if test="identifyCode != null">#{identifyCode,jdbcType=VARCHAR},</if> |
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="orderType != null">#{orderType,jdbcType=INTEGER}</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail">update |
| | | yeshi_ec_user_money_detail set umd_uid = |
| | | #{userInfo.id,jdbcType=BIGINT},umd_money = |
| | | #{money,jdbcType=DECIMAL},umd_type = |
| | | #{type,jdbcType=VARCHAR},umd_title = |
| | | #{title,jdbcType=VARCHAR},umd_sub_title = |
| | | #{subTitle,jdbcType=VARCHAR},umd_desc_info = |
| | | #{descInfo,jdbcType=VARCHAR},umd_source_identify_id = |
| | | #{sourceIdentifyId,jdbcType=BIGINT},umd_identify_code = |
| | | #{identifyCode,jdbcType=VARCHAR},umd_beizhu = |
| | | #{beiZhu,jdbcType=VARCHAR},umd_createtime = |
| | | #{createTime,jdbcType=TIMESTAMP},umd_updatetime = |
| | | #{updateTime,jdbcType=TIMESTAMP} ,umd_order_type |
| | | =#{orderType,jdbcType=INTEGER} where umd_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail"> |
| | | update yeshi_ec_user_money_detail |
| | | <set> |
| | | <if test="userInfo != null">umd_uid=#{userInfo.id,jdbcType=BIGINT},</if> |
| | | <if test="money != null">umd_money=#{money,jdbcType=DECIMAL},</if> |
| | | <if test="type != null">umd_type=#{type,jdbcType=VARCHAR},</if> |
| | | <if test="title != null">umd_title=#{title,jdbcType=VARCHAR},</if> |
| | | <if test="subTitle != null">umd_sub_title=#{subTitle,jdbcType=VARCHAR},</if> |
| | | <if test="descInfo != null">umd_desc_info=#{descInfo,jdbcType=VARCHAR},</if> |
| | | <if test="sourceIdentifyId != null">umd_source_identify_id=#{sourceIdentifyId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="identifyCode != null">umd_identify_code=#{identifyCode,jdbcType=VARCHAR},</if> |
| | | <if test="beiZhu != null">umd_beizhu=#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">umd_createtime=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">umd_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="orderType !=null">umd_order_type =#{orderType,jdbcType=INTEGER},</if> |
| | | </set> |
| | | where umd_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
| | | <?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.money.UserMoneyDetailMapper">
|
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.money.UserMoneyDetail">
|
| | | <id column="umd_id" property="id" jdbcType="BIGINT" />
|
| | | <result column="umd_money" property="money" jdbcType="DECIMAL" />
|
| | | <result column="umd_type" property="type"
|
| | | typeHandler="com.yeshi.fanli.util.mybatishandler.UserMoneyDetailTypeEnumHandler" />
|
| | | <result column="umd_title" property="title" jdbcType="VARCHAR" />
|
| | | <result column="umd_sub_title" property="subTitle" jdbcType="VARCHAR" />
|
| | | <result column="umd_desc_info" property="descInfo" jdbcType="VARCHAR" />
|
| | | <result column="umd_source_identify_id" property="sourceIdentifyId"
|
| | | jdbcType="BIGINT" />
|
| | | <result column="umd_identify_code" property="identifyCode"
|
| | | jdbcType="VARCHAR" />
|
| | | <result column="umd_beizhu" property="beiZhu" jdbcType="VARCHAR" />
|
| | | <result column="umd_createtime" property="createTime" jdbcType="TIMESTAMP" />
|
| | | <result column="umd_updatetime" property="updateTime" jdbcType="TIMESTAMP" />
|
| | | <!-- 老版明细适用该字段 -->
|
| | | <result column="state" property="state" jdbcType="INTEGER" />
|
| | | <result column="umd_order_type" property="orderType" jdbcType="INTEGER" />
|
| | | <result column="umd_show" property="show" jdbcType="BOOLEAN" />
|
| | | <association property="userInfo" column="umd_uid"
|
| | | javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
|
| | | <id column="umd_uid" property="id" jdbcType="BIGINT" />
|
| | | </association>
|
| | |
|
| | | </resultMap>
|
| | | <resultMap id="UserMonthMoneyMap" type="com.yeshi.fanli.vo.money.UserMonthMoneyVO">
|
| | | <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">umd_id,umd_uid,umd_money,umd_type,umd_title,umd_sub_title,umd_desc_info,umd_source_identify_id,umd_identify_code,umd_beizhu,umd_createtime,umd_updatetime,umd_order_type,umd_show
|
| | | </sql>
|
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
| | | parameterType="java.lang.Long">
|
| | | select
|
| | | <include refid="Base_Column_List" />
|
| | | from yeshi_ec_user_money_detail where umd_id = #{id,jdbcType=BIGINT}
|
| | | </select>
|
| | | <select id="selectByUidWithIndexId" resultMap="BaseResultMap">
|
| | | SELECT
|
| | | <include refid="Base_Column_List" />
|
| | | FROM yeshi_ec_user_money_detail d WHERE d.`umd_createtime` <![CDATA[
|
| | | <=
|
| | | ]]>
|
| | | (SELECT d.`umd_createtime` FROM yeshi_ec_user_money_detail d WHERE
|
| | | d.`umd_id`=#{id}) and d.umd_uid=#{uid} and d.umd_show=1 order by d.`umd_createtime`
|
| | | desc,d.umd_id desc limit #{count}
|
| | | </select>
|
| | | <select id="selectCountByUid" resultType="java.lang.Long"
|
| | | parameterType="java.lang.Long">SELECT count(umd_id) FROM yeshi_ec_user_money_detail
|
| | | where umd_uid=#{uid} and umd_show=1 </select>
|
| | | <select id="selectByMaxCreateTime" resultMap="BaseResultMap">
|
| | | SELECT
|
| | | <include refid="Base_Column_List" />
|
| | | FROM yeshi_ec_user_money_detail d WHERE d.umd_uid=#{uid} and d.umd_show=1 and
|
| | | d.`umd_createtime`<![CDATA[
|
| | | <=
|
| | | ]]>
|
| | | #{date} order by d.`umd_createtime` desc,d.umd_id desc limit #{count}
|
| | | </select>
|
| | | <select id="selectCountByUidAndMaxCreateTime" resultType="java.lang.Long">SELECT
|
| | | count(umd_id) FROM yeshi_ec_user_money_detail where umd_uid=#{uid} and d.umd_show=1 and
|
| | | `umd_createtime`<![CDATA[
|
| | | <=
|
| | | ]]>
|
| | | #{date}
|
| | | </select>
|
| | | <select id="selectMonthCountByUid" resultType="java.lang.Integer">SELECT
|
| | | COUNT(*) FROM (SELECT * FROM yeshi_ec_user_money_detail d WHERE
|
| | | d.`umd_uid`=#{uid} and d.umd_show=1 and d.`umd_createtime` <![CDATA[<=]]>
|
| | | #{date} group by DATE_FORMAT(d.`umd_createtime`,'%y-%m')) a
|
| | | </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.`umd_createtime`,'%Y-%m') AS `time`,SUM(d.`umd_money`) AS money
|
| | | FROM `yeshi_ec_user_money_detail` d WHERE d.`umd_uid`=#{uid} and d.umd_show=1 AND
|
| | | d.`umd_money`>=0 AND DATE_FORMAT(
|
| | | d.`umd_createtime`,'%Y-%m')=#{item} GROUP BY DATE_FORMAT(
|
| | | d.`umd_createtime`,'%Y-%m') ) a on a.time=c.time LEFT JOIN ( SELECT
|
| | | DATE_FORMAT( d.`umd_createtime`,'%Y-%m') AS
|
| | | `time`,SUM(d.`umd_money`) AS money FROM `yeshi_ec_user_money_detail`
|
| | | d WHERE d.`umd_uid`=#{uid} and d.umd_show=1 AND d.`umd_money`<![CDATA[<0]]>
|
| | | AND DATE_FORMAT( d.`umd_createtime`,'%Y-%m')=#{item} GROUP BY
|
| | | DATE_FORMAT( d.`umd_createtime`,'%Y-%m') ) b ON c.time=b.time
|
| | | </trim>
|
| | | </foreach>
|
| | | </select>
|
| | | <select id="selectByUidWithState" resultMap="BaseResultMap">SELECT a.* FROM
|
| | | ((SELECT d.*,-1 AS state FROM `yeshi_ec_user_money_detail` d WHERE
|
| | | d.`umd_uid`=#{uid} AND (d.`umd_type`!='extract' AND
|
| | | d.`umd_type`!='extractReject') ) UNION ALL( SELECT d.*,-1 AS state
|
| | | FROM `yeshi_ec_user_money_detail` d LEFT JOIN `yeshi_ec_extract` e ON
|
| | | e.`id`=d.umd_source_identify_id WHERE d.`umd_uid`=#{uid} AND
|
| | | d.umd_type='extractReject' ) UNION ALL( SELECT d.*,e.state FROM
|
| | | `yeshi_ec_user_money_detail` d LEFT JOIN `yeshi_ec_extract` e ON
|
| | | e.`id`=d.`umd_source_identify_id` WHERE d.`umd_uid`=#{uid} AND
|
| | | d.umd_type='extract' )) a ORDER BY a.umd_createtime DESC LIMIT
|
| | | #{start},#{count}</select>
|
| | | <select id="selectCountByUidWithState" resultType="java.lang.Long">SELECT
|
| | | count(*) FROM ((SELECT d.*,-1 AS state FROM
|
| | | `yeshi_ec_user_money_detail` d WHERE d.`umd_uid`=#{uid} AND
|
| | | (d.`umd_type`!='extract' AND d.`umd_type`!='extractReject') ) UNION
|
| | | ALL( SELECT d.*,-1 AS state FROM `yeshi_ec_user_money_detail` d LEFT
|
| | | JOIN `yeshi_ec_extract` e ON e.`id`=d.umd_source_identify_id WHERE
|
| | | d.`umd_uid`=#{uid} AND d.umd_type='extractReject' ) UNION ALL( SELECT
|
| | | d.*,e.state FROM `yeshi_ec_user_money_detail` d LEFT JOIN
|
| | | `yeshi_ec_extract` e ON e.`id`=d.`umd_source_identify_id` WHERE
|
| | | d.`umd_uid`=#{uid} AND d.umd_type='extract' )) a</select>
|
| | | <select id="getTotalMoneyByTypeAndUidWithDate" resultType="java.math.BigDecimal">select
|
| | | sum(umd_money) from yeshi_ec_user_money_detail where umd_uid=#{uid}
|
| | | and umd_createtime>=#{minDate} and umd_createtime<![CDATA[<]]>#{maxDate}
|
| | | <foreach collection="typeList" item="item" open=" and ("
|
| | | separator=" or " close=")">umd_type=#{item}</foreach>
|
| | | </select>
|
| | | <select id="selectByTypeAndUidAndIdentifyCode" resultMap="BaseResultMap">
|
| | | select
|
| | | <include refid="Base_Column_List" />
|
| | | from yeshi_ec_user_money_detail where umd_uid=#{uid} and
|
| | | umd_type=#{type} and umd_source_identify_id=#{sourceIdentifyId}
|
| | | </select>
|
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
| | | yeshi_ec_user_money_detail where umd_id = #{id,jdbcType=BIGINT}
|
| | | </delete>
|
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail"
|
| | | useGeneratedKeys="true" keyProperty="id">insert into
|
| | | yeshi_ec_user_money_detail
|
| | | (umd_id,umd_uid,umd_money,umd_type,umd_title,umd_sub_title,umd_desc_info,umd_source_identify_id,umd_identify_code,umd_beizhu,umd_createtime,umd_updatetime,umd_order_type,umd_show)
|
| | | values
|
| | | (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=VARCHAR},#{title,jdbcType=VARCHAR},#{subTitle,jdbcType=VARCHAR},#{descInfo,jdbcType=VARCHAR},#{sourceIdentifyId,jdbcType=BIGINT},#{identifyCode,jdbcType=VARCHAR},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{orderType,jdbcType=INTEGER},#{show,jdbcType=BOOLEAN})
|
| | | </insert>
|
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail"
|
| | | useGeneratedKeys="true" keyProperty="id">
|
| | | insert into yeshi_ec_user_money_detail
|
| | | <trim prefix="(" suffix=")" suffixOverrides=",">
|
| | | <if test="id != null">umd_id,</if>
|
| | | <if test="userInfo != null">umd_uid,</if>
|
| | | <if test="money != null">umd_money,</if>
|
| | | <if test="type != null">umd_type,</if>
|
| | | <if test="title != null">umd_title,</if>
|
| | | <if test="subTitle != null">umd_sub_title,</if>
|
| | | <if test="descInfo != null">umd_desc_info,</if>
|
| | | <if test="sourceIdentifyId != null">umd_source_identify_id,</if>
|
| | | <if test="identifyCode != null">umd_identify_code,</if>
|
| | | <if test="beiZhu != null">umd_beizhu,</if>
|
| | | <if test="createTime != null">umd_createtime,</if>
|
| | | <if test="updateTime != null">umd_updatetime,</if>
|
| | | <if test="orderType != null">umd_order_type,</if>
|
| | | <if test="show != null">umd_show,</if>
|
| | | </trim>
|
| | | values
|
| | | <trim prefix="(" suffix=")" suffixOverrides=",">
|
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if>
|
| | | <if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT},</if>
|
| | | <if test="money != null">#{money,jdbcType=DECIMAL},</if>
|
| | | <if test="type != null">#{type,jdbcType=VARCHAR},</if>
|
| | | <if test="title != null">#{title,jdbcType=VARCHAR},</if>
|
| | | <if test="subTitle != null">#{subTitle,jdbcType=VARCHAR},</if>
|
| | | <if test="descInfo != null">#{descInfo,jdbcType=VARCHAR},</if>
|
| | | <if test="sourceIdentifyId != null">#{sourceIdentifyId,jdbcType=BIGINT},</if>
|
| | | <if test="identifyCode != null">#{identifyCode,jdbcType=VARCHAR},</if>
|
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if>
|
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="orderType != null">#{orderType,jdbcType=INTEGER}</if>
|
| | | <if test="show != null">#{show,jdbcType=BOOLEAN}</if>
|
| | | </trim>
|
| | | </insert>
|
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail">update
|
| | | yeshi_ec_user_money_detail set umd_uid =
|
| | | #{userInfo.id,jdbcType=BIGINT},umd_money =
|
| | | #{money,jdbcType=DECIMAL},umd_type =
|
| | | #{type,jdbcType=VARCHAR},umd_title =
|
| | | #{title,jdbcType=VARCHAR},umd_sub_title =
|
| | | #{subTitle,jdbcType=VARCHAR},umd_desc_info =
|
| | | #{descInfo,jdbcType=VARCHAR},umd_source_identify_id =
|
| | | #{sourceIdentifyId,jdbcType=BIGINT},umd_identify_code =
|
| | | #{identifyCode,jdbcType=VARCHAR},umd_beizhu =
|
| | | #{beiZhu,jdbcType=VARCHAR},umd_createtime =
|
| | | #{createTime,jdbcType=TIMESTAMP},umd_updatetime =
|
| | | #{updateTime,jdbcType=TIMESTAMP} ,umd_order_type
|
| | | =#{orderType,jdbcType=INTEGER},umd_show
|
| | | =#{show,jdbcType=BOOLEAN} where umd_id = #{id,jdbcType=BIGINT}
|
| | | </update>
|
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail">
|
| | | update yeshi_ec_user_money_detail
|
| | | <set>
|
| | | <if test="userInfo != null">umd_uid=#{userInfo.id,jdbcType=BIGINT},</if>
|
| | | <if test="money != null">umd_money=#{money,jdbcType=DECIMAL},</if>
|
| | | <if test="type != null">umd_type=#{type,jdbcType=VARCHAR},</if>
|
| | | <if test="title != null">umd_title=#{title,jdbcType=VARCHAR},</if>
|
| | | <if test="subTitle != null">umd_sub_title=#{subTitle,jdbcType=VARCHAR},</if>
|
| | | <if test="descInfo != null">umd_desc_info=#{descInfo,jdbcType=VARCHAR},</if>
|
| | | <if test="sourceIdentifyId != null">umd_source_identify_id=#{sourceIdentifyId,jdbcType=BIGINT},
|
| | | </if>
|
| | | <if test="identifyCode != null">umd_identify_code=#{identifyCode,jdbcType=VARCHAR},</if>
|
| | | <if test="beiZhu != null">umd_beizhu=#{beiZhu,jdbcType=VARCHAR},</if>
|
| | | <if test="createTime != null">umd_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="updateTime != null">umd_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="orderType !=null">umd_order_type =#{orderType,jdbcType=INTEGER},</if>
|
| | | <if test="show !=null">umd_show =#{show,jdbcType=BOOLEAN},</if>
|
| | | </set>
|
| | | where umd_id = #{id,jdbcType=BIGINT}
|
| | | </update>
|
| | | </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.mq.MQUnSendInfoMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.mq.MQUnSendInfo"> |
| | | <id column="mui_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="mui_topic" property="topic" jdbcType="VARCHAR" /> |
| | | <result column="mui_tag" property="tag" jdbcType="VARCHAR" /> |
| | | <result column="mui_body" property="body" jdbcType="VARCHAR" /> |
| | | <result column="mui_key" property="key" jdbcType="VARCHAR" /> |
| | | <result column="mui_deliver_time" property="deliverTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="mui_last_send_time" property="lastSendTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">mui_id,mui_topic,mui_tag,mui_body,mui_key,mui_deliver_time,mui_last_send_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_mq_unsend_info where mui_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <select id="selectByTopicTagAndKey" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_mq_unsend_info where mui_topic = #{topic} and |
| | | mui_tag=#{tag} and mui_key=#{key} limit 1 |
| | | </select> |
| | | |
| | | |
| | | <select id="listByMaxSendTime" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_mq_unsend_info where #{maxSendTime} > mui_last_send_time |
| | | order by mui_last_send_time limit #{start},#{count} |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_mq_unsend_info where mui_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.mq.MQUnSendInfo" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_mq_unsend_info |
| | | (mui_id,mui_topic,mui_tag,mui_body,mui_key,mui_deliver_time,mui_last_send_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{topic,jdbcType=VARCHAR},#{tag,jdbcType=VARCHAR},#{body,jdbcType=VARCHAR},#{key,jdbcType=VARCHAR},#{deliverTime,jdbcType=TIMESTAMP},#{lastSendTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.mq.MQUnSendInfo" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_mq_unsend_info |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">mui_id,</if> |
| | | <if test="topic != null">mui_topic,</if> |
| | | <if test="tag != null">mui_tag,</if> |
| | | <if test="body != null">mui_body,</if> |
| | | <if test="key != null">mui_key,</if> |
| | | <if test="deliverTime != null">mui_deliver_time,</if> |
| | | <if test="lastSendTime != null">mui_last_send_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="topic != null">#{topic,jdbcType=VARCHAR},</if> |
| | | <if test="tag != null">#{tag,jdbcType=VARCHAR},</if> |
| | | <if test="body != null">#{body,jdbcType=VARCHAR},</if> |
| | | <if test="key != null">#{key,jdbcType=VARCHAR},</if> |
| | | <if test="deliverTime != null">#{deliverTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="lastSendTime != null">#{lastSendTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.mq.MQUnSendInfo">update |
| | | yeshi_ec_mq_unsend_info set mui_topic = |
| | | #{topic,jdbcType=VARCHAR},mui_tag = #{tag,jdbcType=VARCHAR},mui_body |
| | | = |
| | | #{body,jdbcType=VARCHAR},mui_key = |
| | | #{key,jdbcType=VARCHAR},mui_deliver_time = |
| | | #{deliverTime,jdbcType=TIMESTAMP},mui_last_send_time = |
| | | #{lastSendTime,jdbcType=TIMESTAMP} where mui_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.mq.MQUnSendInfo"> |
| | | update yeshi_ec_mq_unsend_info |
| | | <set> |
| | | <if test="topic != null">mui_topic=#{topic,jdbcType=VARCHAR},</if> |
| | | <if test="tag != null">mui_tag=#{tag,jdbcType=VARCHAR},</if> |
| | | <if test="body != null">mui_body=#{body,jdbcType=VARCHAR},</if> |
| | | <if test="key != null">mui_key=#{key,jdbcType=VARCHAR},</if> |
| | | <if test="deliverTime != null">mui_deliver_time=#{deliverTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="lastSendTime != null">mui_last_send_time=#{lastSendTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | </set> |
| | | where mui_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
| | |
| | | (co.`co_estimate`>=#{money} OR co.`co_eIncome`>=#{money}) |
| | | </select> |
| | | |
| | | <select id="countWeiQuanOrderByUid" |
| | | resultType="java.lang.Integer"> |
| | | SELECT COUNT(*) FROM |
| | | <select id="countWeiQuanOrderByUid" resultType="java.lang.Integer"> |
| | | SELECT COUNT(*) |
| | | FROM |
| | | ( |
| | | SELECT IF(v.`hb_pid` IS NOT |
| | | NULL,p.`hb_id`,v.`hb_id`) AS id FROM |
| | |
| | | wo.`tmo_id`>0 and wo |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <select id="listByOrderIdAndSourceType" resultMap="BaseResultMap"> |
| | | SELECT ho.* |
| | | FROM yeshi_ec_common_order co LEFT JOIN yeshi_ec_hongbao_order |
| | | ho ON |
| | | ho.`ho_order_id`=co.`co_id` WHERE co.`co_order_no`=#{orderId} AND |
| | | co.`co_source_type`=#{sourceType} AND ho.`ho_id`>0 |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_hongbao_order where ho_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.order.HongBaoOrder" |
| | | useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_hongbao_order |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_hongbao_order |
| | | (ho_id,ho_hongbao_id,ho_order_id,ho_create_time) values |
| | | (#{id,jdbcType=BIGINT},#{hongBaoV2.id,jdbcType=BIGINT},#{commonOrder.id,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | |
| | | <!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.order.InviteOrderSubsidyMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.order.InviteOrderSubsidy"> |
| | | <id column="os_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="os_uid" property="uid" jdbcType="BIGINT"/> |
| | | <result column="os_money" property="money" jdbcType="DECIMAL"/> |
| | | <result column="os_order_no" property="orderNo" jdbcType="VARCHAR"/> |
| | | <result column="os_source_type" property="sourceType" jdbcType="INTEGER"/> |
| | | <result column="os_state" property="state" jdbcType="INTEGER"/> |
| | | <result column="os_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="os_update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">os_id,os_uid,os_money,os_order_no,os_source_type,os_state,os_create_time,os_update_time</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_ec_invite_order_subsidy where os_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_invite_order_subsidy where os_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_invite_order_subsidy (os_id,os_uid,os_money,os_order_no,os_source_type,os_state,os_create_time,os_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{orderNo,jdbcType=VARCHAR},#{sourceType,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_invite_order_subsidy |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">os_id,</if> |
| | | <if test="uid != null">os_uid,</if> |
| | | <if test="money != null">os_money,</if> |
| | | <if test="orderNo != null">os_order_no,</if> |
| | | <if test="sourceType != null">os_source_type,</if> |
| | | <if test="state != null">os_state,</if> |
| | | <if test="createTime != null">os_create_time,</if> |
| | | <if test="updateTime != null">os_update_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="orderNo != null">#{orderNo,jdbcType=VARCHAR},</if> |
| | | <if test="sourceType != null">#{sourceType,jdbcType=INTEGER},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</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.order.InviteOrderSubsidy">update yeshi_ec_invite_order_subsidy set os_uid = #{uid,jdbcType=BIGINT},os_money = #{money,jdbcType=DECIMAL},os_order_no = #{orderNo,jdbcType=VARCHAR},os_source_type = #{sourceType,jdbcType=INTEGER},os_state = #{state,jdbcType=INTEGER},os_create_time = #{createTime,jdbcType=TIMESTAMP},os_update_time = #{updateTime,jdbcType=TIMESTAMP} where os_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy">update yeshi_ec_invite_order_subsidy |
| | | <set> |
| | | <if test="uid != null">os_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="money != null">os_money=#{money,jdbcType=DECIMAL},</if> |
| | | <if test="orderNo != null">os_order_no=#{orderNo,jdbcType=VARCHAR},</if> |
| | | <if test="sourceType != null">os_source_type=#{sourceType,jdbcType=INTEGER},</if> |
| | | <if test="state != null">os_state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">os_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">os_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> where os_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | |
| | | <select id="getByOrderNoAndType" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_ec_invite_order_subsidy |
| | | WHERE os_uid = #{uid} AND os_order_no = #{orderNo} AND os_source_type = #{type} |
| | | LIMIT 1 |
| | | </select> |
| | | |
| | | <resultMap id="BaseResultMap" |
| | | type="com.yeshi.fanli.entity.order.InviteOrderSubsidy"> |
| | | <id column="os_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="os_uid" property="uid" jdbcType="BIGINT" /> |
| | | <result column="os_money" property="money" jdbcType="DECIMAL" /> |
| | | <result column="os_order_no" property="orderNo" jdbcType="VARCHAR" /> |
| | | <result column="os_source_type" property="sourceType" jdbcType="INTEGER" /> |
| | | <result column="os_state" property="state" jdbcType="INTEGER" /> |
| | | <result column="os_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="os_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | <result column="os_original_money" property="originalMoney" |
| | | jdbcType="DECIMAL" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">os_id,os_uid,os_money,os_order_no,os_source_type,os_state,os_create_time,os_update_time,os_original_money |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_invite_order_subsidy where os_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <select id="listByOrderNoAndType" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_invite_order_subsidy where os_order_no = #{orderNo} AND |
| | | os_source_type = #{type} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_invite_order_subsidy where os_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_invite_order_subsidy |
| | | (os_id,os_uid,os_money,os_order_no,os_source_type,os_state,os_create_time,os_update_time,os_original_money) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{orderNo,jdbcType=VARCHAR},#{sourceType,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{originalMoney,jdbcType=DECIMAL}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_invite_order_subsidy |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">os_id,</if> |
| | | <if test="uid != null">os_uid,</if> |
| | | <if test="money != null">os_money,</if> |
| | | <if test="orderNo != null">os_order_no,</if> |
| | | <if test="sourceType != null">os_source_type,</if> |
| | | <if test="state != null">os_state,</if> |
| | | <if test="createTime != null">os_create_time,</if> |
| | | <if test="updateTime != null">os_update_time,</if> |
| | | <if test="originalMoney != null">os_original_money,</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="orderNo != null">#{orderNo,jdbcType=VARCHAR},</if> |
| | | <if test="sourceType != null">#{sourceType,jdbcType=INTEGER},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="originalMoney != null">#{originalMoney,jdbcType=DECIMAL}</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy">update |
| | | yeshi_ec_invite_order_subsidy set os_uid = |
| | | #{uid,jdbcType=BIGINT},os_money = |
| | | #{money,jdbcType=DECIMAL},os_order_no = |
| | | #{orderNo,jdbcType=VARCHAR},os_source_type = |
| | | #{sourceType,jdbcType=INTEGER},os_state = |
| | | #{state,jdbcType=INTEGER},os_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},os_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} ,os_original_money |
| | | =#{originalMoney,jdbcType=DECIMAL} where os_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy"> |
| | | update yeshi_ec_invite_order_subsidy |
| | | <set> |
| | | <if test="uid != null">os_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="money != null">os_money=#{money,jdbcType=DECIMAL},</if> |
| | | <if test="orderNo != null">os_order_no=#{orderNo,jdbcType=VARCHAR},</if> |
| | | <if test="sourceType != null">os_source_type=#{sourceType,jdbcType=INTEGER},</if> |
| | | <if test="state != null">os_state=#{state,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">os_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">os_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="originalMoney !=null">os_original_money =#{originalMoney,jdbcType=DECIMAL}, |
| | | </if> |
| | | </set> |
| | | where os_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <select id="getByOrderNoAndType" resultMap="BaseResultMap">SELECT * FROM |
| | | yeshi_ec_invite_order_subsidy WHERE os_uid = #{uid} AND os_order_no = |
| | | #{orderNo} AND os_source_type = #{type} LIMIT 1 |
| | | </select> |
| | | |
| | | <select id="getByOrderNoAndTypeForUpdate" resultMap="BaseResultMap">SELECT * |
| | | FROM |
| | | yeshi_ec_invite_order_subsidy WHERE os_uid = #{uid} AND |
| | | os_order_no = |
| | | #{orderNo} AND os_source_type = #{type} for update |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="countByOrderNoAndType" resultType="java.lang.Long">SELECT count(*) |
| | | FROM yeshi_ec_invite_order_subsidy WHERE os_order_no = #{orderNo} AND |
| | | os_source_type = #{type} |
| | | </select> |
| | | </mapper> |
| | |
| | | </set> |
| | | where ohm_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | |
| | | |
| | | |
| | | <select id="getCouponHongbaoByOrderNo" resultType="java.math.BigDecimal"> |
| | | SELECT COALESCE(SUM(hb.`hb_money`),0)AS couponMoney |
| | | SELECT |
| | | COALESCE(SUM(hb.`hb_money`),0)AS couponMoney |
| | | FROM `yeshi_ec_order_hongbaov2_map` hm |
| | | LEFT JOIN `yeshi_ec_order` o ON o.`id` = hm.`ohm_order_id` |
| | | LEFT JOIN (SELECT v2.`hb_money`,v2.`hb_id` FROM yeshi_ec_hongbao_v2 v2 |
| | | WHERE v2.`hb_uid`= #{uid} AND v2.`hb_type` = 10 )hb ON hb.hb_id = hm.`ohm_hongbao_id` |
| | | WHERE hb.hb_id IS NOT NULL AND o.`orderid` = #{orderNo} |
| | | LEFT JOIN `yeshi_ec_order` o ON |
| | | o.`id` = hm.`ohm_order_id` |
| | | LEFT JOIN (SELECT v2.`hb_money`,v2.`hb_id` |
| | | FROM yeshi_ec_hongbao_v2 v2 |
| | | WHERE v2.`hb_uid`= #{uid} AND v2.`hb_type` = 10 )hb ON hb.hb_id = |
| | | hm.`ohm_hongbao_id` |
| | | WHERE hb.hb_id IS NOT NULL AND o.`orderid` = |
| | | #{orderNo} |
| | | </select> |
| | | |
| | | |
| | | <select id="listByOrderId" resultMap="BaseResultMap"> |
| | | select * from yeshi_ec_order_hongbaov2_map where ohm_order_id=#{0} |
| | | </select> |
| | | |
| | | |
| | | |
| | | </mapper> |
| | |
| | | <?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.taobao.TaoBaoWeiQuanOrderMapper"> |
| | | <resultMap id="BaseResultMap" |
| | | type="com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder"> |
| | | <id column="tmo_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="tmo_order_id" property="orderId" jdbcType="VARCHAR" /> |
| | | <result column="tmo_order_item_id" property="orderItemId" |
| | | jdbcType="VARCHAR" /> |
| | | <result column="tmo_goods_name" property="goodsName" jdbcType="VARCHAR" /> |
| | | <result column="tmo_money" property="money" jdbcType="DECIMAL" /> |
| | | <result column="tmo_fan_money" property="fanMoney" jdbcType="DECIMAL" /> |
| | | <result column="tmo_state" property="state" jdbcType="VARCHAR" /> |
| | | <result column="tmo_jiesuan_time" property="jieSuanTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="tmo_weiquan_time" property="weiQuanTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="tmo_weiquan_finish_time" property="weiQuanFinishTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="tmo_createtime" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="tmo_updatetime" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | <result column="tmo_settlement" property="settlement" jdbcType="DECIMAL" /> |
| | | </resultMap> |
| | | |
| | | <resultMap id="ChartMap" type="com.yeshi.fanli.dto.ChartTDO"> |
| | | <result column="showDate" property="showDate" jdbcType="VARCHAR" /> |
| | | <result column="showValue" property="showValue" jdbcType="VARCHAR" /> |
| | | </resultMap> |
| | | |
| | | |
| | | <sql id="Base_Column_List">tmo_id,tmo_order_id,tmo_order_item_id,tmo_goods_name,tmo_money,tmo_fan_money,tmo_state,tmo_jiesuan_time,tmo_weiquan_time,tmo_weiquan_finish_time,tmo_createtime,tmo_updatetime,tmo_settlement |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_taobao_weiqaun_order where tmo_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <select id="selectByOrderIdAndOrderItemId" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_taobao_weiqaun_order where tmo_order_id =#{orderId} and |
| | | tmo_order_item_id=#{orderItemId} |
| | | </select> |
| | | <select id="selectListByOrderIdAndState" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_taobao_weiqaun_order where tmo_order_id =#{orderId} and |
| | | tmo_state like '${state}%' |
| | | </select> |
| | | <select id="selectByOrderItemId" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_taobao_weiqaun_order where tmo_order_item_id =#{0} |
| | | </select> |
| | | |
| | | |
| | | <select id="listByOrderId" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_taobao_weiqaun_order |
| | | where tmo_order_id=#{0} |
| | | </select> |
| | | |
| | | |
| | | <select id="listByState" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_taobao_weiqaun_order |
| | | <if test="state!=null">where tmo_state like '${state}%'</if> |
| | | order by tmo_createtime desc limit #{start},#{count} |
| | | </select> |
| | | |
| | | <select id="countByState" resultType="java.lang.Long" |
| | | parameterType="java.lang.String"> |
| | | select |
| | | count(*) |
| | | from yeshi_ec_taobao_weiqaun_order |
| | | <if test="state!=null">where tmo_state like '${state}%'</if> |
| | | </select> |
| | | |
| | | |
| | | <select id="selectByOrderItem" resultMap="BaseResultMap" parameterType="java.lang.String"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_taobao_weiqaun_order |
| | | where tmo_order_item_id=#{0} |
| | | </select> |
| | | |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_taobao_weiqaun_order where tmo_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_taobao_weiqaun_order |
| | | (tmo_id,tmo_order_id,tmo_order_item_id,tmo_goods_name,tmo_money,tmo_fan_money,tmo_state,tmo_jiesuan_time,tmo_weiquan_time,tmo_weiquan_finish_time,tmo_createtime,tmo_updatetime,tmo_settlement) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{orderId,jdbcType=VARCHAR},#{orderItemId,jdbcType=VARCHAR},#{goodsName,jdbcType=VARCHAR},#{money,jdbcType=DECIMAL},#{fanMoney,jdbcType=DECIMAL},#{state,jdbcType=VARCHAR},#{jieSuanTime,jdbcType=TIMESTAMP},#{weiQuanTime,jdbcType=TIMESTAMP},#{weiQuanFinishTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{settlement,jdbcType=DECIMAL}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_taobao_weiqaun_order |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">tmo_id,</if> |
| | | <if test="orderId != null">tmo_order_id,</if> |
| | | <if test="orderItemId != null">tmo_order_item_id,</if> |
| | | <if test="goodsName != null">tmo_goods_name,</if> |
| | | <if test="money != null">tmo_money,</if> |
| | | <if test="fanMoney != null">tmo_fan_money,</if> |
| | | <if test="state != null">tmo_state,</if> |
| | | <if test="jieSuanTime != null">tmo_jiesuan_time,</if> |
| | | <if test="weiQuanTime != null">tmo_weiquan_time,</if> |
| | | <if test="weiQuanFinishTime != null">tmo_weiquan_finish_time,</if> |
| | | <if test="createTime != null">tmo_createtime,</if> |
| | | <if test="updateTime != null">tmo_updatetime,</if> |
| | | <if test="settlement != null">tmo_settlement,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if> |
| | | <if test="orderItemId != null">#{orderItemId,jdbcType=VARCHAR},</if> |
| | | <if test="goodsName != null">#{goodsName,jdbcType=VARCHAR},</if> |
| | | <if test="money != null">#{money,jdbcType=DECIMAL},</if> |
| | | <if test="fanMoney != null">#{fanMoney,jdbcType=DECIMAL},</if> |
| | | <if test="state != null">#{state,jdbcType=VARCHAR},</if> |
| | | <if test="jieSuanTime != null">#{jieSuanTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="weiQuanTime != null">#{weiQuanTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="weiQuanFinishTime != null">#{weiQuanFinishTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="settlement != null">#{settlement,jdbcType=DECIMAL}</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder">update |
| | | yeshi_ec_taobao_weiqaun_order set tmo_order_id = |
| | | #{orderId,jdbcType=VARCHAR},tmo_order_item_id = |
| | | #{orderItemId,jdbcType=VARCHAR},tmo_goods_name = |
| | | #{goodsName,jdbcType=VARCHAR},tmo_money = |
| | | #{money,jdbcType=DECIMAL},tmo_fan_money = |
| | | #{fanMoney,jdbcType=DECIMAL},tmo_state = |
| | | #{state,jdbcType=VARCHAR},tmo_jiesuan_time = |
| | | #{jieSuanTime,jdbcType=TIMESTAMP},tmo_weiquan_time = |
| | | #{weiQuanTime,jdbcType=TIMESTAMP},tmo_weiquan_finish_time = |
| | | #{weiQuanFinishTime,jdbcType=TIMESTAMP},tmo_createtime = |
| | | #{createTime,jdbcType=TIMESTAMP},tmo_updatetime = |
| | | #{updateTime,jdbcType=TIMESTAMP} ,tmo_settlement |
| | | =#{settlement,jdbcType=DECIMAL} where tmo_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder"> |
| | | update yeshi_ec_taobao_weiqaun_order |
| | | <set> |
| | | <if test="orderId != null">tmo_order_id=#{orderId,jdbcType=VARCHAR},</if> |
| | | <if test="orderItemId != null">tmo_order_item_id=#{orderItemId,jdbcType=VARCHAR},</if> |
| | | <if test="goodsName != null">tmo_goods_name=#{goodsName,jdbcType=VARCHAR},</if> |
| | | <if test="money != null">tmo_money=#{money,jdbcType=DECIMAL},</if> |
| | | <if test="fanMoney != null">tmo_fan_money=#{fanMoney,jdbcType=DECIMAL},</if> |
| | | <if test="state != null">tmo_state=#{state,jdbcType=VARCHAR},</if> |
| | | <if test="jieSuanTime != null">tmo_jiesuan_time=#{jieSuanTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="weiQuanTime != null">tmo_weiquan_time=#{weiQuanTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="weiQuanFinishTime != null">tmo_weiquan_finish_time=#{weiQuanFinishTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="createTime != null">tmo_createtime=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">tmo_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="settlement !=null">tmo_settlement =#{settlement,jdbcType=DECIMAL},</if> |
| | | </set> |
| | | where tmo_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <sql id="Column_DateType"> |
| | | <if test="dateType == 1">DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m-%d') AS 'showDate' |
| | | </if> |
| | | <if test="dateType == 2">DATE_FORMAT(t.`tmo_weiquan_time`,'%m') AS 'showDate'</if> |
| | | <if test="dateType == 3">DATE_FORMAT(t.`tmo_weiquan_time`,'%Y') AS 'showDate'</if> |
| | | </sql> |
| | | <sql id="Count_Select_DateType"> |
| | | <if test="startTime != null and startTime != '' "> |
| | | AND DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}' |
| | | </if> |
| | | <if test="endTime != null and endTime != '' "> |
| | | AND DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}' |
| | | </if> |
| | | <if test="year != null and year != '' ">AND DATE_FORMAT(t.`tmo_weiquan_time`,'%Y') = '${year}' |
| | | </if> |
| | | </sql> |
| | | <sql id="Count_Group_DateType"> |
| | | <if test="dateType == 1">GROUP BY DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m-%d')</if> |
| | | <if test="dateType == 2">GROUP BY DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m')</if> |
| | | <if test="dateType == 3">GROUP BY DATE_FORMAT(t.`tmo_weiquan_time`,'%Y')</if> |
| | | </sql> |
| | | <select id="countWeiQaunOrderNumber" resultMap="ChartMap"> |
| | | SELECT IFNULL(COUNT(t.`tmo_id`),0) AS showValue, |
| | | <include refid="Column_DateType" /> |
| | | FROM yeshi_ec_taobao_weiqaun_order t WHERE t.`tmo_createtime`IS NOT |
| | | NULL |
| | | <include refid="Count_Select_DateType" /> |
| | | <include refid="Count_Group_DateType" /> |
| | | ORDER BY t.`tmo_weiquan_time` |
| | | </select> |
| | | <select id="countWeiQaunOrderMoney" resultMap="ChartMap"> |
| | | SELECT CAST(SUM(t.`tmo_fan_money`)AS DECIMAL(19,2)) AS showValue, |
| | | <include refid="Column_DateType" /> |
| | | FROM yeshi_ec_taobao_weiqaun_order t WHERE t.`tmo_createtime` IS NOT |
| | | NULL |
| | | <include refid="Count_Select_DateType" /> |
| | | <include refid="Count_Group_DateType" /> |
| | | ORDER BY t.`tmo_weiquan_time` |
| | | </select> |
| | | </mapper> |
| | | <?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.taobao.TaoBaoWeiQuanOrderMapper">
|
| | | <resultMap id="BaseResultMap"
|
| | | type="com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder">
|
| | | <id column="tmo_id" property="id" jdbcType="BIGINT" />
|
| | | <result column="tmo_order_id" property="orderId" jdbcType="VARCHAR" />
|
| | | <result column="tmo_order_item_id" property="orderItemId"
|
| | | jdbcType="VARCHAR" />
|
| | | <result column="tmo_goods_name" property="goodsName" jdbcType="VARCHAR" />
|
| | | <result column="tmo_money" property="money" jdbcType="DECIMAL" />
|
| | | <result column="tmo_fan_money" property="fanMoney" jdbcType="DECIMAL" />
|
| | | <result column="tmo_state" property="state" jdbcType="VARCHAR" />
|
| | | <result column="tmo_jiesuan_time" property="jieSuanTime"
|
| | | jdbcType="TIMESTAMP" />
|
| | | <result column="tmo_weiquan_time" property="weiQuanTime"
|
| | | jdbcType="TIMESTAMP" />
|
| | | <result column="tmo_weiquan_finish_time" property="weiQuanFinishTime"
|
| | | jdbcType="TIMESTAMP" />
|
| | | <result column="tmo_createtime" property="createTime" jdbcType="TIMESTAMP" />
|
| | | <result column="tmo_updatetime" property="updateTime" jdbcType="TIMESTAMP" />
|
| | | <result column="tmo_settlement" property="settlement" jdbcType="DECIMAL" />
|
| | | </resultMap>
|
| | | |
| | | <resultMap id="ChartMap" type="com.yeshi.fanli.dto.ChartTDO">
|
| | | <result column="showDate" property="showDate" jdbcType="VARCHAR" />
|
| | | <result column="showValue" property="showValue" jdbcType="VARCHAR" />
|
| | | </resultMap>
|
| | | |
| | | |
| | | <sql id="Base_Column_List">tmo_id,tmo_order_id,tmo_order_item_id,tmo_goods_name,tmo_money,tmo_fan_money,tmo_state,tmo_jiesuan_time,tmo_weiquan_time,tmo_weiquan_finish_time,tmo_createtime,tmo_updatetime,tmo_settlement
|
| | | </sql>
|
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
| | | parameterType="java.lang.Long">
|
| | | select
|
| | | <include refid="Base_Column_List" />
|
| | | from yeshi_ec_taobao_weiqaun_order where tmo_id =
|
| | | #{id,jdbcType=BIGINT}
|
| | | </select>
|
| | | <select id="selectByOrderIdAndOrderItemId" resultMap="BaseResultMap">
|
| | | select
|
| | | <include refid="Base_Column_List" />
|
| | | from yeshi_ec_taobao_weiqaun_order where tmo_order_id =#{orderId} and
|
| | | tmo_order_item_id=#{orderItemId}
|
| | | </select>
|
| | | <select id="selectListByOrderIdAndState" resultMap="BaseResultMap">
|
| | | select
|
| | | <include refid="Base_Column_List" />
|
| | | from yeshi_ec_taobao_weiqaun_order where tmo_order_id =#{orderId} and
|
| | | tmo_state like '${state}%'
|
| | | </select>
|
| | | <select id="selectByOrderItemId" resultMap="BaseResultMap">
|
| | | select
|
| | | <include refid="Base_Column_List" />
|
| | | from yeshi_ec_taobao_weiqaun_order where tmo_order_item_id =#{0}
|
| | | </select>
|
| | |
|
| | |
|
| | | <select id="listByOrderId" resultMap="BaseResultMap">
|
| | | select
|
| | | <include refid="Base_Column_List" />
|
| | | from yeshi_ec_taobao_weiqaun_order
|
| | | where tmo_order_id=#{0}
|
| | | </select>
|
| | |
|
| | |
|
| | | <select id="listByState" resultMap="BaseResultMap">
|
| | | select
|
| | | <include refid="Base_Column_List" />
|
| | | from yeshi_ec_taobao_weiqaun_order
|
| | | <if test="state!=null">where tmo_state like '${state}%'</if>
|
| | | order by tmo_createtime desc limit #{start},#{count}
|
| | | </select>
|
| | |
|
| | | <select id="countByState" resultType="java.lang.Long"
|
| | | parameterType="java.lang.String">
|
| | | select
|
| | | count(*)
|
| | | from yeshi_ec_taobao_weiqaun_order
|
| | | <if test="state!=null">where tmo_state like '${state}%'</if>
|
| | | </select>
|
| | | |
| | | |
| | | <select id="selectByOrderItem" resultMap="BaseResultMap" parameterType="java.lang.String">
|
| | | select
|
| | | <include refid="Base_Column_List" />
|
| | | from yeshi_ec_taobao_weiqaun_order
|
| | | where tmo_order_item_id=#{0}
|
| | | </select>
|
| | |
|
| | |
|
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
| | | yeshi_ec_taobao_weiqaun_order where tmo_id = #{id,jdbcType=BIGINT}
|
| | | </delete>
|
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder"
|
| | | useGeneratedKeys="true" keyProperty="id">insert into
|
| | | yeshi_ec_taobao_weiqaun_order
|
| | | (tmo_id,tmo_order_id,tmo_order_item_id,tmo_goods_name,tmo_money,tmo_fan_money,tmo_state,tmo_jiesuan_time,tmo_weiquan_time,tmo_weiquan_finish_time,tmo_createtime,tmo_updatetime,tmo_settlement)
|
| | | values
|
| | | (#{id,jdbcType=BIGINT},#{orderId,jdbcType=VARCHAR},#{orderItemId,jdbcType=VARCHAR},#{goodsName,jdbcType=VARCHAR},#{money,jdbcType=DECIMAL},#{fanMoney,jdbcType=DECIMAL},#{state,jdbcType=VARCHAR},#{jieSuanTime,jdbcType=TIMESTAMP},#{weiQuanTime,jdbcType=TIMESTAMP},#{weiQuanFinishTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{settlement,jdbcType=DECIMAL})
|
| | | </insert>
|
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder"
|
| | | useGeneratedKeys="true" keyProperty="id">
|
| | | insert into yeshi_ec_taobao_weiqaun_order
|
| | | <trim prefix="(" suffix=")" suffixOverrides=",">
|
| | | <if test="id != null">tmo_id,</if>
|
| | | <if test="orderId != null">tmo_order_id,</if>
|
| | | <if test="orderItemId != null">tmo_order_item_id,</if>
|
| | | <if test="goodsName != null">tmo_goods_name,</if>
|
| | | <if test="money != null">tmo_money,</if>
|
| | | <if test="fanMoney != null">tmo_fan_money,</if>
|
| | | <if test="state != null">tmo_state,</if>
|
| | | <if test="jieSuanTime != null">tmo_jiesuan_time,</if>
|
| | | <if test="weiQuanTime != null">tmo_weiquan_time,</if>
|
| | | <if test="weiQuanFinishTime != null">tmo_weiquan_finish_time,</if>
|
| | | <if test="createTime != null">tmo_createtime,</if>
|
| | | <if test="updateTime != null">tmo_updatetime,</if>
|
| | | <if test="settlement != null">tmo_settlement,</if>
|
| | | </trim>
|
| | | values
|
| | | <trim prefix="(" suffix=")" suffixOverrides=",">
|
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if>
|
| | | <if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
|
| | | <if test="orderItemId != null">#{orderItemId,jdbcType=VARCHAR},</if>
|
| | | <if test="goodsName != null">#{goodsName,jdbcType=VARCHAR},</if>
|
| | | <if test="money != null">#{money,jdbcType=DECIMAL},</if>
|
| | | <if test="fanMoney != null">#{fanMoney,jdbcType=DECIMAL},</if>
|
| | | <if test="state != null">#{state,jdbcType=VARCHAR},</if>
|
| | | <if test="jieSuanTime != null">#{jieSuanTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="weiQuanTime != null">#{weiQuanTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="weiQuanFinishTime != null">#{weiQuanFinishTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="settlement != null">#{settlement,jdbcType=DECIMAL}</if>
|
| | | </trim>
|
| | | </insert>
|
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder">update
|
| | | yeshi_ec_taobao_weiqaun_order set tmo_order_id =
|
| | | #{orderId,jdbcType=VARCHAR},tmo_order_item_id =
|
| | | #{orderItemId,jdbcType=VARCHAR},tmo_goods_name =
|
| | | #{goodsName,jdbcType=VARCHAR},tmo_money =
|
| | | #{money,jdbcType=DECIMAL},tmo_fan_money =
|
| | | #{fanMoney,jdbcType=DECIMAL},tmo_state =
|
| | | #{state,jdbcType=VARCHAR},tmo_jiesuan_time =
|
| | | #{jieSuanTime,jdbcType=TIMESTAMP},tmo_weiquan_time =
|
| | | #{weiQuanTime,jdbcType=TIMESTAMP},tmo_weiquan_finish_time =
|
| | | #{weiQuanFinishTime,jdbcType=TIMESTAMP},tmo_createtime =
|
| | | #{createTime,jdbcType=TIMESTAMP},tmo_updatetime =
|
| | | #{updateTime,jdbcType=TIMESTAMP} ,tmo_settlement
|
| | | =#{settlement,jdbcType=DECIMAL} where tmo_id = #{id,jdbcType=BIGINT}
|
| | | </update>
|
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder">
|
| | | update yeshi_ec_taobao_weiqaun_order
|
| | | <set>
|
| | | <if test="orderId != null">tmo_order_id=#{orderId,jdbcType=VARCHAR},</if>
|
| | | <if test="orderItemId != null">tmo_order_item_id=#{orderItemId,jdbcType=VARCHAR},</if>
|
| | | <if test="goodsName != null">tmo_goods_name=#{goodsName,jdbcType=VARCHAR},</if>
|
| | | <if test="money != null">tmo_money=#{money,jdbcType=DECIMAL},</if>
|
| | | <if test="fanMoney != null">tmo_fan_money=#{fanMoney,jdbcType=DECIMAL},</if>
|
| | | <if test="state != null">tmo_state=#{state,jdbcType=VARCHAR},</if>
|
| | | <if test="jieSuanTime != null">tmo_jiesuan_time=#{jieSuanTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="weiQuanTime != null">tmo_weiquan_time=#{weiQuanTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="weiQuanFinishTime != null">tmo_weiquan_finish_time=#{weiQuanFinishTime,jdbcType=TIMESTAMP},
|
| | | </if>
|
| | | <if test="createTime != null">tmo_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="updateTime != null">tmo_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
|
| | | <if test="settlement !=null">tmo_settlement =#{settlement,jdbcType=DECIMAL},</if>
|
| | | </set>
|
| | | where tmo_id = #{id,jdbcType=BIGINT}
|
| | | </update>
|
| | | <sql id="Column_DateType">
|
| | | <if test="dateType == 1">DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m-%d') AS 'showDate'
|
| | | </if>
|
| | | <if test="dateType == 2">DATE_FORMAT(t.`tmo_weiquan_time`,'%m') AS 'showDate'</if>
|
| | | <if test="dateType == 3">DATE_FORMAT(t.`tmo_weiquan_time`,'%Y') AS 'showDate'</if>
|
| | | </sql>
|
| | | <sql id="Count_Select_DateType">
|
| | | <if test="startTime != null and startTime != '' ">
|
| | | AND DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
|
| | | </if>
|
| | | <if test="endTime != null and endTime != '' ">
|
| | | AND DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
|
| | | </if>
|
| | | <if test="year != null and year != '' ">AND DATE_FORMAT(t.`tmo_weiquan_time`,'%Y') = '${year}'
|
| | | </if>
|
| | | </sql>
|
| | | <sql id="Count_Group_DateType">
|
| | | <if test="dateType == 1">GROUP BY DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m-%d')</if>
|
| | | <if test="dateType == 2">GROUP BY DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m')</if>
|
| | | <if test="dateType == 3">GROUP BY DATE_FORMAT(t.`tmo_weiquan_time`,'%Y')</if>
|
| | | </sql>
|
| | | <select id="countWeiQaunOrderNumber" resultMap="ChartMap">
|
| | | SELECT IFNULL(COUNT(t.`tmo_id`),0) AS showValue,
|
| | | <include refid="Column_DateType" />
|
| | | FROM yeshi_ec_taobao_weiqaun_order t WHERE t.`tmo_createtime`IS NOT
|
| | | NULL
|
| | | <include refid="Count_Select_DateType" />
|
| | | <include refid="Count_Group_DateType" />
|
| | | ORDER BY t.`tmo_weiquan_time`
|
| | | </select>
|
| | | <select id="countWeiQaunOrderMoney" resultMap="ChartMap">
|
| | | SELECT CAST(SUM(t.`tmo_fan_money`)AS DECIMAL(19,2)) AS showValue,
|
| | | <include refid="Column_DateType" />
|
| | | FROM yeshi_ec_taobao_weiqaun_order t WHERE t.`tmo_createtime` IS NOT
|
| | | NULL
|
| | | <include refid="Count_Select_DateType" />
|
| | | <include refid="Count_Group_DateType" />
|
| | | ORDER BY t.`tmo_weiquan_time`
|
| | | </select>
|
| | | </mapper>
|
| | |
| | | List<Integer> cidList = new ArrayList<>();
|
| | | cidList.add(1);// 女装
|
| | | int sort = getCommonSort(cid);
|
| | | result = DaTaoKeApiUtil.search("内衣 女", cidList, null, null, page, pageSize, sort);
|
| | | result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort);
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | long count = 0;
|
| | | if (result != null) {
|
| | |
| | |
|
| | | List<TLJBuyGoods> list = tljBuyGoodsService
|
| | | .listByDay(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
|
| | |
|
| | | if (list.size() > 20)
|
| | | list = list.subList(0, 20);
|
| | | List<TaoBaoGoodsBrief> finalList = new ArrayList<>();
|
| | | Map<Long, TLJBuyGoods> map = new ConcurrentHashMap<>();
|
| | | if (list != null)
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.hongbao;
|
| | |
|
| | | 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.hongbao.HongBaoV2SettleTempMapper;
|
| | | import com.yeshi.fanli.entity.order.HongBaoV2SettleTemp;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2SettleTempService;
|
| | |
|
| | | @Service
|
| | | public class HongBaoV2SettleTempServiceImpl implements HongBaoV2SettleTempService {
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2SettleTempMapper hongBaoV2SettleTempMapper;
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void addTemp(List<Long> hongBaoIdList, String taskKey) {
|
| | | for (Long hbId : hongBaoIdList) {
|
| | | HongBaoV2SettleTemp temp = new HongBaoV2SettleTemp();
|
| | | temp.setCreateTime(new Date());
|
| | | temp.setHongBaoId(hbId);
|
| | | temp.setTaskKey(taskKey);
|
| | | hongBaoV2SettleTempMapper.insertSelective(temp);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<HongBaoV2SettleTemp> listByKey(String key) {
|
| | | return hongBaoV2SettleTempMapper.listByKey(key);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countByKey(String key) {
|
| | | return hongBaoV2SettleTempMapper.countByKey(key);
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | 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.money.InviteOrderSubsidyDebtMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.money.InviteOrderSubsidyDebtRepayHistoryMapper;
|
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt;
|
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebtRepayHistory;
|
| | | import com.yeshi.fanli.exception.money.InviteOrderSubsidyDebtException;
|
| | | import com.yeshi.fanli.service.inter.money.InviteOrderSubsidyDebtService;
|
| | |
|
| | | @Service
|
| | | public class InviteOrderSubsidyDebtServiceImpl implements InviteOrderSubsidyDebtService {
|
| | | @Resource
|
| | | private InviteOrderSubsidyDebtMapper inviteOrderSubsidyDebtMapper;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyDebtRepayHistoryMapper inviteOrderSubsidyDebtRepayHistoryMapper;
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void addDebt(InviteOrderSubsidyDebt debt) throws InviteOrderSubsidyDebtException {
|
| | | if (debt == null || debt.getOriginMoney() == null || debt.getOriginMoney() == null || debt.getUid() == null) {
|
| | | throw new InviteOrderSubsidyDebtException(1, "数据不完整");
|
| | | }
|
| | | if (debt.getCreateTime() == null)
|
| | | debt.setCreateTime(new Date());
|
| | | debt.setLeftMoney(debt.getOriginMoney());
|
| | | inviteOrderSubsidyDebtMapper.insertSelective(debt);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void repayDebt(Long debtId, BigDecimal money) throws InviteOrderSubsidyDebtException {
|
| | | InviteOrderSubsidyDebt debt = inviteOrderSubsidyDebtMapper.selectByPrimaryKeyForUpdate(debtId);
|
| | | if (debt == null)
|
| | | throw new InviteOrderSubsidyDebtException(1, "债务ID不存在");
|
| | | if (money == null || money.compareTo(new BigDecimal(0)) <= 0)
|
| | | throw new InviteOrderSubsidyDebtException(3, "还钱必须大于0");
|
| | | if (debt.getLeftMoney().compareTo(money) < 0)
|
| | | throw new InviteOrderSubsidyDebtException(2, "还钱过多");
|
| | | // 还钱
|
| | | InviteOrderSubsidyDebt update = new InviteOrderSubsidyDebt();
|
| | | update.setId(debt.getId());
|
| | | update.setLeftMoney(debt.getLeftMoney().subtract(money));
|
| | | update.setUpdateTime(new Date());
|
| | | inviteOrderSubsidyDebtMapper.updateByPrimaryKeySelective(update);
|
| | | // 加入还钱记录
|
| | | InviteOrderSubsidyDebtRepayHistory record = new InviteOrderSubsidyDebtRepayHistory();
|
| | | record.setCreateTime(new Date());
|
| | | record.setDebt(debt);
|
| | | record.setMoney(money);
|
| | | record.setUid(debt.getUid());
|
| | | inviteOrderSubsidyDebtRepayHistoryMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public BigDecimal repayDebtByUid(Long uid, BigDecimal money) throws InviteOrderSubsidyDebtException {
|
| | | // 还钱
|
| | | long count = countNeedRepayDebt(uid);
|
| | | int page = (int) (count % 200 == 0 ? count / 200 : count / 200 + 1);
|
| | | List<InviteOrderSubsidyDebt> totalList = new ArrayList<>();
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<InviteOrderSubsidyDebt> tempList = listNeedRepayDebt(uid, i + 1, 200);
|
| | | if (tempList != null && tempList.size() > 0) {
|
| | | totalList.addAll(tempList);
|
| | | }
|
| | | }
|
| | |
|
| | | // 剩余资金
|
| | | BigDecimal leftMoney = new BigDecimal(money.toString());
|
| | |
|
| | | for (InviteOrderSubsidyDebt debt : totalList) {
|
| | | if (leftMoney.compareTo(new BigDecimal(0)) <= 0)// 余额不足扣款
|
| | | break;
|
| | | BigDecimal repayMoney = null;
|
| | | if (debt.getLeftMoney().compareTo(leftMoney) >= 0)
|
| | | repayMoney = new BigDecimal(leftMoney.toString());
|
| | | else
|
| | | repayMoney = debt.getLeftMoney();
|
| | | try {
|
| | | repayDebt(debt.getId(), repayMoney);
|
| | | leftMoney = leftMoney.subtract(repayMoney);
|
| | | } catch (InviteOrderSubsidyDebtException e) {
|
| | | // 上笔还款未成功,继续下一笔还款
|
| | | }
|
| | | }
|
| | |
|
| | | return leftMoney;//返回剩余的资金
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<InviteOrderSubsidyDebt> listNeedRepayDebt(Long uid, int page, int count) {
|
| | | return inviteOrderSubsidyDebtMapper.listByLeftMoneyAndUid(new BigDecimal("0.01"), null, uid, (page - 1) * count,
|
| | | count);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countNeedRepayDebt(Long uid) {
|
| | | return inviteOrderSubsidyDebtMapper.countByLeftMoneyAndUid(new BigDecimal("0.01"), null, uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getTotalDebtMoney(Long uid) {
|
| | | BigDecimal money = inviteOrderSubsidyDebtMapper.sumLeftMoneyByUid(uid);
|
| | | if (money == null)
|
| | | money = new BigDecimal(0);
|
| | | return money;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | @Resource
|
| | | private OrderUserStatisticService orderUserStatisticService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ExtractWeiXinRecordService extractWeiXinRecordService;
|
| | | |
| | |
|
| | | @Transactional
|
| | | public Integer addExtract(Extract extract) {
|
| | |
| | | * @param extract
|
| | | * @param session
|
| | | */
|
| | | //TODO 转账逻辑需要改变,固定IP
|
| | | // TODO 转账逻辑需要改变,固定IP
|
| | | @Transactional
|
| | | private void extractByZhiFuBao(Extract extract, AdminUser adminUser) {
|
| | | LogHelper.userErrorInfo("提现:开始通过提现-"+extract.getId());
|
| | | LogHelper.userErrorInfo("提现:开始通过提现-" + extract.getId());
|
| | | String privateKey = Constant.alipayConfig.getPrivateKey();
|
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",
|
| | | Constant.alipayConfig.getAppId(), privateKey, "json", "gbk", null, "RSA2");
|
| | | AlipayFundTransToaccountTransferRequest request = new AlipayFundTransToaccountTransferRequest();
|
| | | String appName = Constant.systemCommonConfig.getProjectChineseName();
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("out_biz_no", "widthdraw_"+extract.getId());//最长长度64位,支持英文,下划线,数字
|
| | | json.put("out_biz_no", "widthdraw_" + extract.getId());// 最长长度64位,支持英文,下划线,数字
|
| | | json.put("payee_type", "ALIPAY_LOGONID");
|
| | | json.put("payee_account", extract.getAccount());
|
| | | json.put("amount", extract.getMoney());
|
| | |
| | | AlipayFundTransToaccountTransferResponse response = null;
|
| | | try {
|
| | | response = alipayClient.execute(request);
|
| | | LogHelper.userErrorInfo("提现:支付宝通过提现成功-"+extract.getId());
|
| | | LogHelper.userErrorInfo("提现:支付宝通过提现成功-" + extract.getId());
|
| | | } catch (AlipayApiException e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.userErrorInfo("提现:支付宝提现异常:" + response + ",提现信息" + GsonUtil.toJson(extract));
|
| | |
| | |
|
| | | try {
|
| | | CMQManager.getInstance().addExtractResultMsg(extract, response, adminUser);
|
| | | LogHelper.userErrorInfo("提现:添加处理队列成功-"+extract.getId());
|
| | | LogHelper.userErrorInfo("提现:添加处理队列成功-" + extract.getId());
|
| | | } catch (Exception e) {
|
| | | LogHelper.userErrorInfo("提现:支付宝提现CMQ异常:" + new Gson().toJson(response) + ",提现信息" + GsonUtil.toJson(extract));
|
| | | LogHelper
|
| | | .userErrorInfo("提现:支付宝提现CMQ异常:" + new Gson().toJson(response) + ",提现信息" + GsonUtil.toJson(extract));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | // 更新提现记录审核表
|
| | | extractAuditRecordMapper.updateByPrimaryKeySelective(auditRecord);
|
| | | }
|
| | |
|
| | | // 外显账户明细
|
| | | UserMoneyDetail userMoneyDetail = userMoneyDetailMapper.selectByTypeAndUidAndIdentifyCode(
|
| | | UserMoneyDetailTypeEnum.extract, extract.getUserInfo().getId(), extract.getId());
|
| | | if (userMoneyDetail != null) {
|
| | | UserMoneyDetail detail = new UserMoneyDetail(userMoneyDetail.getId());
|
| | | detail.setShow(true);
|
| | | detail.setUpdateTime(new Date());
|
| | | userMoneyDetailMapper.updateByPrimaryKeySelective(detail);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal sumTodayApplyMoney(Long uid,String day) {
|
| | | return extractMapper.sumToadyApplyByUid(uid,day);
|
| | | public BigDecimal sumTodayApplyMoney(Long uid, String day) {
|
| | | return extractMapper.sumToadyApplyByUid(uid, day);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal sumVerifyingMoney(Long uid) {
|
| | | List<Integer> stateList=new ArrayList<>();
|
| | | stateList.add(Extract.STATE_NOT_PROCESS);
|
| | | stateList.add(Extract.STATE_PROCESSING);
|
| | | BigDecimal money= extractMapper.sumMoneyByUidAndState(uid, stateList);
|
| | | if(money==null)
|
| | | List<Integer> stateList = new ArrayList<>();
|
| | | stateList.add(Extract.STATE_NOT_PROCESS);
|
| | | stateList.add(Extract.STATE_PROCESSING);
|
| | | BigDecimal money = extractMapper.sumMoneyByUidAndState(uid, stateList);
|
| | | if (money == null)
|
| | | return new BigDecimal(0);
|
| | | else
|
| | | return money;
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void autoExtract(UserInfo user) {
|
| | | if (user == null || user.getWxOpenId() == null || user.getWxUnionId() == null ||
|
| | | user.getState() != UserInfo.STATE_NORMAL)
|
| | | if (user == null || user.getWxOpenId() == null || user.getWxUnionId() == null
|
| | | || user.getState() != UserInfo.STATE_NORMAL)
|
| | | return;
|
| | | |
| | |
|
| | | Date date = new Date();
|
| | | BigDecimal money = new BigDecimal(Constant.AUTO_EXTRACT_MONEY);
|
| | | |
| | |
|
| | | // 1、插入记录
|
| | | ExtractWeiXinRecord extractRecord = new ExtractWeiXinRecord();
|
| | | extractRecord.setUid(user.getId());
|
| | | extractRecord.setOpenId(user.getWxOpenId());
|
| | | extractRecord.setUnionId(user.getWxUnionId() );
|
| | | extractRecord.setUnionId(user.getWxUnionId());
|
| | | extractRecord.setMoney(money);
|
| | | extractRecord.setCreateTime(date);
|
| | | extractRecord.setUpdateTime(date);
|
| | | extractWeiXinRecordService.insertSelective(extractRecord);
|
| | | |
| | |
|
| | | // 交易号
|
| | | Long recordId = extractRecord.getId();
|
| | | String billno = "BanLiExtract" + recordId;
|
| | | |
| | |
|
| | | // 更新记录
|
| | | ExtractWeiXinRecord updeteRecord = null;
|
| | | |
| | |
|
| | | String mchId = "1520950211";
|
| | | String appId = "wx5c0d167c6e3ad726";
|
| | | String key = "XYJkJ2018FAfaodCCx899mLl138rfGVd";
|
| | | |
| | |
|
| | | // 2、发放微信红包
|
| | | RedPackParams redPackParams = new RedPackParams();
|
| | | redPackParams.setBillno(billno);
|
| | |
| | | redPackParams.setActName("自动提现");
|
| | | redPackParams.setKey(key);
|
| | | redPackParams.setRemark("微信自动提现");
|
| | | //redPackParams.setSceneId(null);
|
| | | //redPackParams.setRiskInfo(null);
|
| | | |
| | | |
| | | // redPackParams.setSceneId(null);
|
| | | // redPackParams.setRiskInfo(null);
|
| | |
|
| | | // 发生红包状态
|
| | | boolean stateRedPack = false;
|
| | | |
| | |
|
| | | String pwd = "1520950211";
|
| | | InputStream cert = ExtractServiceImpl.class.getClassLoader().getResourceAsStream("certificate/apiclient_cert.p12"); // 读取.p12文件
|
| | | InputStream cert = ExtractServiceImpl.class.getClassLoader()
|
| | | .getResourceAsStream("certificate/apiclient_cert.p12"); // 读取.p12文件
|
| | | // 执行发放红包
|
| | | try {
|
| | | String result = WXPayUtil.redPackToOpenId(redPackParams, pwd, cert);
|
| | | if (!StringUtil.isNullOrEmpty(result)) {
|
| | | stateRedPack = parseSendResult(result);
|
| | | }
|
| | | |
| | |
|
| | | if (!stateRedPack) {
|
| | | String redPackRecord = WXPayUtil.getRedPackRecord(billno, mchId, appId, key, pwd, cert);
|
| | | if (!StringUtil.isNullOrEmpty(redPackRecord)) {
|
| | |
| | | } catch (IOException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | |
| | |
|
| | | // 更新信息
|
| | | if (updeteRecord == null) {
|
| | | updeteRecord = new ExtractWeiXinRecord();
|
| | | } else {
|
| | | stateRedPack = true;
|
| | | }
|
| | | |
| | |
|
| | | updeteRecord.setId(recordId);
|
| | | updeteRecord.setStatus(ExtractWeiXinRecord.SENDING);
|
| | | updeteRecord.setBillno(billno);
|
| | | extractWeiXinRecordService.updateByPrimaryKeySelective(updeteRecord);
|
| | | |
| | |
|
| | | // 红包发放失败
|
| | | if (!stateRedPack) |
| | | return; |
| | | |
| | | if (!stateRedPack)
|
| | | return;
|
| | |
|
| | | // 3、加入资金明细
|
| | | UserMoneyDetail detail = new UserMoneyDetail();
|
| | | detail.setCreateTime(new Date());
|
| | |
| | | } catch (UserMoneyDetailException e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | |
| | |
|
| | | // 4、发送消息通知
|
| | | String desc = "为保障你的账户余额安全,自动提现金额将不会高于5元";
|
| | | String beizu = "账户中剩余余额请在本App内完成提现";
|
| | | userMoneyMsgNotificationService.extractAuto(extractRecord, "未领取-提现中", desc, beizu);
|
| | | }
|
| | |
|
| | | |
| | | private boolean parseSendResult(String result) {
|
| | | try {
|
| | | Document document = DocumentHelper.parseText(result);
|
| | | // 获取根节点元素对象
|
| | | Element root = document.getRootElement();
|
| | | Element returnCode = root.element("return_code");
|
| | | |
| | | if (!"SUCCESS".equalsIgnoreCase(returnCode.getText())) {
|
| | | Element returnMsg = root.element("return_msg");
|
| | | System.out.println(returnMsg.getText()); |
| | | return false;
|
| | | } |
| | | |
| | | Element resultCode = root.element("result_code");
|
| | | if (!"SUCCESS".equalsIgnoreCase(resultCode.getText())) {
|
| | | Element errCode = root.element("err_code");
|
| | | Element errCodeDes = root.element("err_code_des");
|
| | | System.out.println(errCode.getText() + ":" + errCodeDes.getText()); |
| | | return false;
|
| | | }
|
| | | return true;
|
| | | Element root = document.getRootElement();
|
| | | Element returnCode = root.element("return_code");
|
| | |
|
| | | if (!"SUCCESS".equalsIgnoreCase(returnCode.getText())) {
|
| | | Element returnMsg = root.element("return_msg");
|
| | | System.out.println(returnMsg.getText());
|
| | | return false;
|
| | | }
|
| | |
|
| | | Element resultCode = root.element("result_code");
|
| | | if (!"SUCCESS".equalsIgnoreCase(resultCode.getText())) {
|
| | | Element errCode = root.element("err_code");
|
| | | Element errCodeDes = root.element("err_code_des");
|
| | | System.out.println(errCode.getText() + ":" + errCodeDes.getText());
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | } catch (DocumentException e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | return false;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | private ExtractWeiXinRecord parseDTO(String result) {
|
| | | try {
|
| | | |
| | |
|
| | | Document document = DocumentHelper.parseText(result);
|
| | | // 获取根节点元素对象
|
| | | Element root = document.getRootElement();
|
| | | Element returnCode = root.element("return_code");
|
| | | |
| | | if (!"SUCCESS".equalsIgnoreCase(returnCode.getText())) {
|
| | | Element returnMsg = root.element("return_msg");
|
| | | System.out.println(returnMsg.getText()); |
| | | return null;
|
| | | } |
| | | |
| | | Element resultCode = root.element("result_code");
|
| | | if (!"SUCCESS".equalsIgnoreCase(resultCode.getText())) {
|
| | | Element errCode = root.element("err_code");
|
| | | Element errCodeDes = root.element("err_code_des");
|
| | | System.out.println(errCode.getText() + ":" + errCodeDes.getText()); |
| | | }
|
| | | |
| | | ExtractWeiXinRecord resultRecord = new ExtractWeiXinRecord();
|
| | | resultRecord.setBillno(root.element("result_code").getText());
|
| | | resultRecord.setDetailno(root.element("detail_id").getText());
|
| | | resultRecord.setStatus(root.element("status").getText());
|
| | | resultRecord.setSendType(root.element("send_type").getText());
|
| | | resultRecord.setHbType(root.element("result_code").getText());
|
| | | |
| | | String totalNum = root.element("total_num").getText();
|
| | | resultRecord.setTotalNum(Integer.parseInt(totalNum));
|
| | | |
| | | String sendTime = root.element("send_time").getText();
|
| | | resultRecord.setSendTime(new Date(TimeUtil.convertDateToTemp2(sendTime)));
|
| | | |
| | | Element element = root.element("hblist");
|
| | | Iterator<?> iterator = element.elementIterator();
|
| | | while (iterator.hasNext()) {
|
| | | Element childElement = (Element)iterator.next();
|
| | | Element rcvTime = childElement.element("rcv_time");
|
| | | resultRecord.setRcvTime(new Date(TimeUtil.convertDateToTemp2(rcvTime.getText())));
|
| | | break;
|
| | | } |
| | | return resultRecord;
|
| | | |
| | | Element root = document.getRootElement();
|
| | | Element returnCode = root.element("return_code");
|
| | |
|
| | | if (!"SUCCESS".equalsIgnoreCase(returnCode.getText())) {
|
| | | Element returnMsg = root.element("return_msg");
|
| | | System.out.println(returnMsg.getText());
|
| | | return null;
|
| | | }
|
| | |
|
| | | Element resultCode = root.element("result_code");
|
| | | if (!"SUCCESS".equalsIgnoreCase(resultCode.getText())) {
|
| | | Element errCode = root.element("err_code");
|
| | | Element errCodeDes = root.element("err_code_des");
|
| | | System.out.println(errCode.getText() + ":" + errCodeDes.getText());
|
| | | }
|
| | |
|
| | | ExtractWeiXinRecord resultRecord = new ExtractWeiXinRecord();
|
| | | resultRecord.setBillno(root.element("result_code").getText());
|
| | | resultRecord.setDetailno(root.element("detail_id").getText());
|
| | | resultRecord.setStatus(root.element("status").getText());
|
| | | resultRecord.setSendType(root.element("send_type").getText());
|
| | | resultRecord.setHbType(root.element("result_code").getText());
|
| | |
|
| | | String totalNum = root.element("total_num").getText();
|
| | | resultRecord.setTotalNum(Integer.parseInt(totalNum));
|
| | |
|
| | | String sendTime = root.element("send_time").getText();
|
| | | resultRecord.setSendTime(new Date(TimeUtil.convertDateToTemp2(sendTime)));
|
| | |
|
| | | Element element = root.element("hblist");
|
| | | Iterator<?> iterator = element.elementIterator();
|
| | | while (iterator.hasNext()) {
|
| | | Element childElement = (Element) iterator.next();
|
| | | Element rcvTime = childElement.element("rcv_time");
|
| | | resultRecord.setRcvTime(new Date(TimeUtil.convertDateToTemp2(rcvTime.getText())));
|
| | | break;
|
| | | }
|
| | | return resultRecord;
|
| | |
|
| | | } catch (DocumentException e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public List<UserInfo> preAutoUser() throws Exception {
|
| | | int page = 0;
|
| | |
| | | String receivedDate = DateUtil.reduceDayTostring(30, nowDate);
|
| | | // 条件4:距离上一次未成功领取微信红包已经超过了15天时间,可在第16天再次下发;
|
| | | String refundDate = DateUtil.reduceDayTostring(15, nowDate);
|
| | | |
| | |
|
| | | // 余额最低限制
|
| | | BigDecimal minSurplus = BigDecimal.valueOf(Constant.AUTO_EXTRACT_MIN_SURPLUS);
|
| | | |
| | |
|
| | | List<UserInfo> list = new ArrayList<UserInfo>();
|
| | | |
| | |
|
| | | while (true) {
|
| | | // 查询满足条件 1、2 的uid
|
| | | List<UserInfo> listUser = userInfoService.getAutoExtractUser(page * pageSize, pageSize, minSurplus, beganDate, endDate);
|
| | | List<UserInfo> listUser = userInfoService.getAutoExtractUser(page * pageSize, pageSize, minSurplus,
|
| | | beganDate, endDate);
|
| | | if (listUser == null || listUser.isEmpty())
|
| | | break;
|
| | | |
| | |
|
| | | List<Long> listId = new ArrayList<Long>();
|
| | | for (UserInfo userInfo: listUser) {
|
| | | for (UserInfo userInfo : listUser) {
|
| | | listId.add(userInfo.getId());
|
| | | }
|
| | | |
| | |
|
| | | // 查询记录是否满足
|
| | | List<Long> listValid = extractWeiXinRecordService.getValidUsers(listId, receivedDate, refundDate);
|
| | | if (listValid == null || listValid.isEmpty()) {
|
| | | page ++;
|
| | | page++;
|
| | | continue;
|
| | | }
|
| | | |
| | | for (Long uid: listValid) {
|
| | |
|
| | | for (Long uid : listValid) {
|
| | | if (list.size() >= maxSize)
|
| | | break;
|
| | | for (UserInfo userInfo: listUser) {
|
| | | for (UserInfo userInfo : listUser) {
|
| | | if (list.size() >= maxSize)
|
| | | break;
|
| | | |
| | |
|
| | | if (userInfo.getId().longValue() == uid.longValue()) {
|
| | | list.add(userInfo);
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (list.size() >= maxSize)
|
| | | break;
|
| | | |
| | | page ++;
|
| | |
|
| | | page++;
|
| | | }
|
| | | return list;
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public List<String> getAutoExtractOpenIds() throws Exception {
|
| | | int page = 0;
|
| | |
| | | String receivedDate = DateUtil.reduceDayTostring(30, nowDate);
|
| | | // 条件4:距离上一次未成功领取微信红包已经超过了15天时间,可在第16天再次下发;
|
| | | String refundDate = DateUtil.reduceDayTostring(15, nowDate);
|
| | | |
| | |
|
| | | // 提现金额
|
| | | BigDecimal money = BigDecimal.valueOf(Constant.AUTO_EXTRACT_MONEY);
|
| | | // 余额最低限制
|
| | | BigDecimal minSurplus = BigDecimal.valueOf(Constant.AUTO_EXTRACT_MIN_SURPLUS);
|
| | | |
| | |
|
| | | List<String> listOpendIDs = new ArrayList<String>();
|
| | | // 首行appID
|
| | | listOpendIDs.add(Constant.getWXAccount(null, null).getAppId());
|
| | | |
| | |
|
| | | while (true) {
|
| | | // 查询满足条件 1、2 的uid
|
| | | List<UserInfo> listUser = userInfoService.getAutoExtractUser(page * pageSize, pageSize, minSurplus, beganDate, endDate);
|
| | | List<UserInfo> listUser = userInfoService.getAutoExtractUser(page * pageSize, pageSize, minSurplus,
|
| | | beganDate, endDate);
|
| | | if (listUser == null || listUser.isEmpty())
|
| | | break;
|
| | | |
| | |
|
| | | List<Long> listId = new ArrayList<Long>();
|
| | | for (UserInfo userInfo: listUser) {
|
| | | for (UserInfo userInfo : listUser) {
|
| | | listId.add(userInfo.getId());
|
| | | }
|
| | | |
| | |
|
| | | // 查询记录是否满足
|
| | | List<Long> listValid = extractWeiXinRecordService.getValidUsers(listId, receivedDate, refundDate);
|
| | | if (listValid == null || listValid.isEmpty()) {
|
| | | page ++;
|
| | | page++;
|
| | | continue;
|
| | | }
|
| | | |
| | | for (Long uid: listValid) {
|
| | |
|
| | | for (Long uid : listValid) {
|
| | | UserInfo userInfo = subHongBaoByUid(uid, money, minSurplus);
|
| | | if (userInfo != null) {
|
| | | listOpendIDs.add(userInfo.getWxOpenId());
|
| | |
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (listOpendIDs.size() >= maxSize)
|
| | | break;
|
| | | |
| | | page ++;
|
| | |
|
| | | page++;
|
| | | }
|
| | | return listOpendIDs;
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private UserInfo subHongBaoByUid(Long uid, BigDecimal money, BigDecimal minSurplus) {
|
| | | UserInfo userInfo = userInfoMapper.selectByPrimaryKeyForUpdate(uid);
|
| | | if (userInfo != null && !StringUtil.isNullOrEmpty(userInfo.getWxOpenId())
|
| | | && !StringUtil.isNullOrEmpty(userInfo.getWxUnionId()) && userInfo.getMyHongBao().compareTo(minSurplus) >= 0) {
|
| | | && !StringUtil.isNullOrEmpty(userInfo.getWxUnionId())
|
| | | && userInfo.getMyHongBao().compareTo(minSurplus) >= 0) {
|
| | | // 微信提现记录
|
| | | ExtractWeiXinRecord extractRecord = new ExtractWeiXinRecord();
|
| | | extractRecord.setUid(uid);
|
| | |
| | | extractWeiXinRecordService.insertSelective(extractRecord);
|
| | | // 记录id
|
| | | Long recordId = extractRecord.getId();
|
| | | |
| | |
|
| | | // 资金明细
|
| | | UserMoneyDetail detail = new UserMoneyDetail();
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.extractAutoWX.name() + ":" + recordId));
|
| | | detail.setMoney(new BigDecimal("-"+ money.toString()));
|
| | | detail.setMoney(new BigDecimal("-" + money.toString()));
|
| | | detail.setTitle(UserMoneyDetailTypeEnum.extractAutoWX.getDesc());
|
| | | detail.setType(UserMoneyDetailTypeEnum.extractAutoWX);
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setUserInfo(userInfo);
|
| | | |
| | |
|
| | | // 资金计算
|
| | | userMoneyService.subUserMoney(userInfo.getId(), money, detail);
|
| | |
|
| | |
| | | String desc = "为保障你的账户余额安全,自动提现金额将不会高于5元";
|
| | | String beizu = "账户中剩余余额请在本App内完成提现";
|
| | | userMoneyMsgNotificationService.extractAuto(extractRecord, "未领取-提现中", desc, beizu);
|
| | | |
| | |
|
| | | // 满足条件返回信息
|
| | | return userInfo;
|
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public void updateManualExtractRecord(List<RedPackRecord> list) throws ExtractException{
|
| | | public void updateManualExtractRecord(List<RedPackRecord> list) throws ExtractException {
|
| | | if (list == null || list.isEmpty())
|
| | | throw new ExtractException(1, "红包记录信息为空");
|
| | | |
| | | for (RedPackRecord redPackRecord: list) {
|
| | |
|
| | | for (RedPackRecord redPackRecord : list) {
|
| | | updateWeiXinRecord(redPackRecord);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private void updateWeiXinRecord(RedPackRecord redPackRecord){
|
| | | private void updateWeiXinRecord(RedPackRecord redPackRecord) {
|
| | | if (StringUtil.isNullOrEmpty(redPackRecord.getOpenId()))
|
| | | return;
|
| | | |
| | | ExtractWeiXinRecord record = extractWeiXinRecordService.getByOpenIdAndType(redPackRecord.getOpenId(), ExtractWeiXinRecord.TYPE_MANUAL);
|
| | |
|
| | | ExtractWeiXinRecord record = extractWeiXinRecordService.getByOpenIdAndType(redPackRecord.getOpenId(),
|
| | | ExtractWeiXinRecord.TYPE_MANUAL);
|
| | | if (record == null)
|
| | | return;
|
| | | |
| | |
|
| | | // 状态过滤
|
| | | String statusOld = record.getStatus();
|
| | | if (StringUtil.isNullOrEmpty(statusOld) || ExtractWeiXinRecord.REFUND.equals(statusOld) |
| | | || ExtractWeiXinRecord.RECEIVED.equals(statusOld)) |
| | | if (StringUtil.isNullOrEmpty(statusOld) || ExtractWeiXinRecord.REFUND.equals(statusOld)
|
| | | || ExtractWeiXinRecord.RECEIVED.equals(statusOld))
|
| | | return;
|
| | | |
| | |
|
| | | ExtractWeiXinRecord updeteRecord = new ExtractWeiXinRecord();
|
| | | updeteRecord.setId(record.getId());
|
| | | updeteRecord.setUpdateTime(new Date());
|
| | | |
| | |
|
| | | String billno = redPackRecord.getBillno();
|
| | | if (!StringUtil.isNullOrEmpty(billno)) {
|
| | | updeteRecord.setBillno(billno.replace("`", "").replace("'", ""));
|
| | | }
|
| | | |
| | |
|
| | | String detailno = redPackRecord.getDetailno();
|
| | | if (!StringUtil.isNullOrEmpty(detailno)) {
|
| | | updeteRecord.setDetailno(detailno.replace("`", "").replace("'", ""));
|
| | | }
|
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
| | | String rcvTime = redPackRecord.getRcvTime();
|
| | | if (!StringUtil.isNullOrEmpty(rcvTime)) {
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | String sendTime = redPackRecord.getSendTime();
|
| | | if (!StringUtil.isNullOrEmpty(sendTime)) {
|
| | | try {
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | String status = redPackRecord.getStatus();
|
| | | if (!StringUtil.isNullOrEmpty(status)) {
|
| | | switch (status) {
|
| | | case "已发放待领取":
|
| | | status = ExtractWeiXinRecord.SENT;
|
| | | break;
|
| | | case "过期未领退款":
|
| | | status = ExtractWeiXinRecord.REFUND;
|
| | | break;
|
| | | case "已领取":
|
| | | status = ExtractWeiXinRecord.RECEIVED;
|
| | | break;
|
| | | default:
|
| | | status = null;
|
| | | break;
|
| | | } |
| | | case "已发放待领取":
|
| | | status = ExtractWeiXinRecord.SENT;
|
| | | break;
|
| | | case "过期未领退款":
|
| | | status = ExtractWeiXinRecord.REFUND;
|
| | | break;
|
| | | case "已领取":
|
| | | status = ExtractWeiXinRecord.RECEIVED;
|
| | | break;
|
| | | default:
|
| | | status = null;
|
| | | break;
|
| | | }
|
| | | }
|
| | | updeteRecord.setStatus(status);
|
| | | extractWeiXinRecordService.updateByPrimaryKeySelective(updeteRecord);
|
| | | |
| | |
|
| | | if (ExtractWeiXinRecord.RECEIVED.equals(status)) {
|
| | | // 发送消息通知
|
| | | userMoneyMsgNotificationService.extractAuto(record, "已领取-已提现", null, null);
|
| | |
| | | // 资金明细
|
| | | UserMoneyDetail detail = new UserMoneyDetail();
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.extractAutoWXRefund.name() + ":" + record.getId()));
|
| | | detail.setIdentifyCode(
|
| | | StringUtil.Md5(UserMoneyDetailTypeEnum.extractAutoWXRefund.name() + ":" + record.getId()));
|
| | | detail.setMoney(record.getMoney());
|
| | | detail.setTitle(UserMoneyDetailTypeEnum.extractAutoWXRefund.getDesc());
|
| | | detail.setType(UserMoneyDetailTypeEnum.extractAutoWXRefund);
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setUserInfo(new UserInfo(record.getUid()));
|
| | | |
| | |
|
| | | // 资金计算
|
| | | userMoneyService.addUserMoney(record.getUid(), record.getMoney(), detail);
|
| | | |
| | |
|
| | | // 发送消息通知
|
| | | userMoneyMsgNotificationService.extractAuto(record, "已退回-余额中", null, null);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanDrawBackMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDebt;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDebt.UserMoneyDebtTypeEnum;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanDrawBack;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.money.InviteOrderSubsidyDebtException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDebtException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.money.InviteOrderSubsidyDebtService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDebtService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.money.tb.TaoBaoWeiQuanDrawBackService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderVO;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyDebtService inviteOrderSubsidyDebtService;
|
| | |
|
| | | @Override
|
| | | public void addWeiQuanDrawBack(TaoBaoWeiQuanDrawBack taoBaoWeiQuanDrawBack) {
|
| | |
| | | List<TaoBaoWeiQuanOrder> list = taoBaoWeiQuanOrderService.getWeiQuanSuccessOrders(orderId);
|
| | | if (list == null || list.size() == 0)
|
| | | return;
|
| | | // 获取和该订单号有关联的用户
|
| | | // 获取主红包(同一个订单号的单只会对应同一个用户)
|
| | | List<CommonOrderVO> typeList = new ArrayList<>();
|
| | | CommonOrderVO cv = new CommonOrderVO();
|
| | | cv.setSourceType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | cv.setOrderNo(orderId);
|
| | | typeList.add(cv);
|
| | | List<HongBaoV2> mainHongBaoList = getWeiQuanMainHongBao(list, orderId);
|
| | |
|
| | | List<CommonOrderVO> commonOrderList = commonOrderMapper.listOrderGoodsInfo(typeList);
|
| | | List<HongBaoV2> mainHongBaoList = new ArrayList<>();
|
| | | if (commonOrderList != null)
|
| | | for (CommonOrderVO vo : commonOrderList) {
|
| | | // 修改订单状态为维权
|
| | | CommonOrder co = new CommonOrder(vo.getId());
|
| | | co.setState(CommonOrder.STATE_WQ);
|
| | | co.setUpdateTime(new Date());
|
| | | commonOrderMapper.updateByPrimaryKeySelective(co);
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(vo.getId());
|
| | | if (hongBaoOrder.getCommonOrder() != null
|
| | | && !StringUtil.isNullOrEmpty(hongBaoOrder.getCommonOrder().getTradeId()))
|
| | | // 查询是否已经维权
|
| | | {
|
| | | TaoBaoWeiQuanDrawBack drawBack = taoBaoWeiQuanDrawBackMapper.selectByOrderItemIdAndUid(
|
| | | hongBaoOrder.getCommonOrder().getTradeId(),
|
| | | hongBaoOrder.getHongBaoV2().getUserInfo().getId());
|
| | | if (drawBack == null)// 添加还未扣款的子订单
|
| | | mainHongBaoList.add(hongBaoOrder.getHongBaoV2());
|
| | | }
|
| | | }
|
| | | if (mainHongBaoList == null || mainHongBaoList.size() == 0)
|
| | | return;
|
| | | for (int i = 0; i < mainHongBaoList.size(); i++) {
|
| | | HongBaoV2 hb = hongBaoV2Mapper.selectByPrimaryKey(mainHongBaoList.get(i).getId());
|
| | | // 锁行,防止重复 操作
|
| | | HongBaoV2 hb = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(mainHongBaoList.get(i).getId());
|
| | | mainHongBaoList.set(i, hb);
|
| | | // 只处理返利订单
|
| | | if (hb.getType() != HongBaoV2.TYPE_ZIGOU) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | private List<HongBaoV2> getWeiQuanMainHongBao(List<TaoBaoWeiQuanOrder> list, String orderId) {
|
| | | // 查询是否为维权订单
|
| | | if (list == null || list.size() == 0)
|
| | | return null;
|
| | | // 获取和该订单号有关联的用户
|
| | | // 查询还未扣款的主红包
|
| | | List<HongBaoV2> mainHongBaoList = new ArrayList<>();
|
| | | for (TaoBaoWeiQuanOrder weiQuanOrder : list) {
|
| | | List<CommonOrder> orderList = commonOrderMapper.listBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | weiQuanOrder.getOrderItemId());
|
| | | if (orderList != null && orderList.size() > 0)
|
| | | for (CommonOrder commonOrder : orderList) {
|
| | | // 修改订单状态为维权
|
| | | CommonOrder co = new CommonOrder(commonOrder.getId());
|
| | | co.setState(CommonOrder.STATE_WQ);
|
| | | co.setUpdateTime(new Date());
|
| | | commonOrderMapper.updateByPrimaryKeySelective(co);
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
|
| | | if (hongBaoOrder.getCommonOrder() != null
|
| | | && !StringUtil.isNullOrEmpty(hongBaoOrder.getCommonOrder().getTradeId()))
|
| | | // 查询是否已经维权
|
| | | {
|
| | | TaoBaoWeiQuanDrawBack drawBack = taoBaoWeiQuanDrawBackMapper.selectByOrderItemIdAndUid(
|
| | | hongBaoOrder.getCommonOrder().getTradeId(),
|
| | | hongBaoOrder.getHongBaoV2().getUserInfo().getId());
|
| | | if (drawBack == null)// 添加还未扣款的子订单
|
| | | mainHongBaoList.add(hongBaoOrder.getHongBaoV2());
|
| | | }
|
| | | }
|
| | | }
|
| | | return mainHongBaoList;
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void doWeiQuanShare(String orderId) throws TaoBaoWeiQuanException {
|
| | | if (StringUtil.isNullOrEmpty(orderId))
|
| | | throw new TaoBaoWeiQuanException(1, "订单号为空值");
|
| | | // 查询是否为维权订单
|
| | | List<TaoBaoWeiQuanOrder> list = taoBaoWeiQuanOrderService.getWeiQuanSuccessOrders(orderId);
|
| | | if (list == null || list.size() == 0)
|
| | | return;
|
| | | // 获取和该订单号有关联的用户
|
| | | // 获取主红包(同一个订单号的单只会对应同一个用户)
|
| | | List<CommonOrderVO> typeList = new ArrayList<>();
|
| | | CommonOrderVO cv = new CommonOrderVO();
|
| | | cv.setSourceType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | cv.setOrderNo(orderId);
|
| | | typeList.add(cv);
|
| | |
|
| | | List<CommonOrderVO> commonOrderList = commonOrderMapper.listOrderGoodsInfo(typeList);
|
| | | List<HongBaoV2> mainHongBaoList = new ArrayList<>();
|
| | | if (commonOrderList != null)
|
| | | for (CommonOrderVO vo : commonOrderList) {
|
| | | // 更改订单状态
|
| | | CommonOrder co = new CommonOrder(vo.getId());
|
| | | co.setState(CommonOrder.STATE_WQ);
|
| | | co.setUpdateTime(new Date());
|
| | | commonOrderMapper.updateByPrimaryKeySelective(co);
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(vo.getId());
|
| | | if (hongBaoOrder.getCommonOrder() != null
|
| | | && !StringUtil.isNullOrEmpty(hongBaoOrder.getCommonOrder().getTradeId()))
|
| | | // 查询是否已经维权
|
| | | {
|
| | | TaoBaoWeiQuanDrawBack drawBack = taoBaoWeiQuanDrawBackMapper.selectByOrderItemIdAndUid(
|
| | | hongBaoOrder.getCommonOrder().getTradeId(),
|
| | | hongBaoOrder.getHongBaoV2().getUserInfo().getId());
|
| | | if (drawBack == null)// 添加还未扣款的子订单
|
| | | mainHongBaoList.add(hongBaoOrder.getHongBaoV2());
|
| | | }
|
| | | }
|
| | | List<TaoBaoWeiQuanOrder> list = taoBaoWeiQuanOrderService.getWeiQuanSuccessOrders(orderId);
|
| | | if(list==null||list.size()==0)
|
| | | return;
|
| | | List<HongBaoV2> mainHongBaoList = getWeiQuanMainHongBao(list, orderId);
|
| | |
|
| | | if (mainHongBaoList == null || mainHongBaoList.size() == 0)
|
| | | return;
|
| | |
| | | weiQuanDrawBack.setUser(child.getUserInfo());
|
| | | taoBaoWeiQuanDrawBackMapper.insertSelective(weiQuanDrawBack);// 加入返还记录
|
| | |
|
| | | // 加入邀请补贴返还记录
|
| | | doInviteOrderSubsidy(orderId, Constant.SOURCE_TYPE_TAOBAO, uid, settleMent, wqMoney);
|
| | |
|
| | | // 如果资金大于0才扣除
|
| | |
|
| | | if (drawBackMoney != null && drawBackMoney.compareTo(new BigDecimal(0)) > 0) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 邀请订单补贴维权处理
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | private void doInviteOrderSubsidy(String orderId, int sourceType, Long uid, BigDecimal settleMent,
|
| | | BigDecimal weiQuanMoney) throws TaoBaoWeiQuanException {
|
| | | InviteOrderSubsidy subSidy = inviteOrderSubsidyService.getByOrderNoAndType(uid, orderId, sourceType);
|
| | | if (subSidy != null)// 添加借贷关系
|
| | | {
|
| | | BigDecimal drawBackMoney = computeDrawBackMoney(settleMent, weiQuanMoney, subSidy.getOriginalMoney());
|
| | | if (drawBackMoney.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | InviteOrderSubsidyDebt debt = new InviteOrderSubsidyDebt();
|
| | | debt.setBeiZhu("订单维权:" + orderId + "-" + sourceType);
|
| | | debt.setOriginMoney(drawBackMoney);
|
| | | debt.setUid(uid);
|
| | | debt.setCreateTime(new Date());
|
| | | try {
|
| | | inviteOrderSubsidyDebtService.addDebt(debt);
|
| | | } catch (InviteOrderSubsidyDebtException e) {
|
| | | throw new TaoBaoWeiQuanException(101, "邀请订单补贴异常");
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TaoBaoWeiQuanDrawBack selectByOrderItemId(String orderItemId) {
|
| | | List<TaoBaoWeiQuanDrawBack> list = taoBaoWeiQuanDrawBackMapper.selectByOrderItemId(orderItemId);
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.mq;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.mq.MQUnSendInfoMapper;
|
| | | import com.yeshi.fanli.entity.mq.MQUnSendInfo;
|
| | | import com.yeshi.fanli.exception.mq.MQUnSendInfoException;
|
| | | import com.yeshi.fanli.service.inter.mq.MQUnSendInfoService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | | public class MQUnSendInfoServiceImpl implements MQUnSendInfoService {
|
| | |
|
| | | @Resource
|
| | | private MQUnSendInfoMapper mqUnSendInfoMapper;
|
| | |
|
| | | @Override
|
| | | public void addMQUnSendInfo(MQUnSendInfo info) throws MQUnSendInfoException {
|
| | | if (StringUtil.isNullOrEmpty(info.getTag()) || StringUtil.isNullOrEmpty(info.getTopic())
|
| | | || StringUtil.isNullOrEmpty(info.getBody()) || StringUtil.isNullOrEmpty(info.getKey())) {
|
| | | throw new MQUnSendInfoException(1, "信息不完整");
|
| | | }
|
| | | MQUnSendInfo oldInfo = mqUnSendInfoMapper.selectByTopicTagAndKey(info.getTopic(), info.getTag(), info.getKey());
|
| | | if (oldInfo != null)
|
| | | return;
|
| | | if (info.getLastSendTime() == null)
|
| | | info.setLastSendTime(new Date());
|
| | | mqUnSendInfoMapper.insertSelective(info);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<MQUnSendInfo> listByMaxSendTime(Date maxSendTime, int page, int pageSize) {
|
| | | return mqUnSendInfoMapper.listByMaxSendTime(maxSendTime, (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteByPrimaryKey(Long id) {
|
| | | mqUnSendInfoMapper.deleteByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void updateSendTime(Long id, Date sendTime) {
|
| | | MQUnSendInfo info = new MQUnSendInfo();
|
| | | info.setId(id);
|
| | | info.setLastSendTime(sendTime);
|
| | | mqUnSendInfoMapper.updateByPrimaryKeySelective(info);
|
| | | }
|
| | | }
|
| | |
| | | return hongBaoOrderMapper.selectByHongBaoId(hongBaoId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<HongBaoOrder> listByOrderIdAndSourceType(String orderId, int sourceType) {
|
| | | return hongBaoOrderMapper.listByOrderIdAndSourceType(orderId, sourceType);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | |
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
|
| | | @Lazy
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | |
|
| | |
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void addHongBao(List<CommonOrder> commonOrderList, int type) throws HongBaoException {
|
| | | public int addHongBao(List<CommonOrder> commonOrderList, int type) throws HongBaoException {
|
| | | Set<Integer> stateSet = new HashSet<>();// 订单状态Set
|
| | | if (commonOrderList != null && commonOrderList.size() > 0) {
|
| | | int orderType = commonOrderList.get(0).getSourceType();
|
| | |
| | | Map<Integer, HongBaoOrder> notificationMap = new HashMap<>();
|
| | | int goodsCount = 0;
|
| | | boolean hasAdd = false;
|
| | | boolean hasUpdate = false;
|
| | | for (CommonOrder commonOrder : commonOrderList) {
|
| | | stateSet.add(commonOrder.getState());
|
| | | goodsCount += commonOrder.getCount();
|
| | |
| | | saveHongBao(commonOrder, type, notificationMap);
|
| | | hasAdd = true;
|
| | | } else {
|
| | | updateHongBao(hongBaoOrder, commonOrder, type, notificationMap);
|
| | | boolean update = updateHongBao(hongBaoOrder, commonOrder, type, notificationMap);
|
| | | if (update)
|
| | | hasUpdate = true;
|
| | | }
|
| | | }
|
| | | /**
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | int resultCode = 0;
|
| | | if (hasAdd && hasUpdate)
|
| | | return 12;
|
| | | else if (hasAdd)
|
| | | return 1;
|
| | | else if (hasUpdate)
|
| | | return 2;
|
| | | return resultCode;
|
| | | }
|
| | | return 0;
|
| | | }
|
| | |
|
| | | private int getOrderState(Set<Integer> states) {
|
| | |
| | | }
|
| | |
|
| | | @Transactional
|
| | | private void updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type,
|
| | | private boolean updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type,
|
| | | Map<Integer, HongBaoOrder> notificationMap) throws HongBaoException {
|
| | | System.out.println(commonOrder.getOrderNo());
|
| | | // 锁行
|
| | |
| | | throw new HongBaoException(10, "红包对象不存在");
|
| | | // 已经失效,已经领取,新老状态一致的红包不做处理
|
| | | if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | return;
|
| | | return false;
|
| | |
|
| | | if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
|
| | | BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
|
| | |
| | |
|
| | | // 新老红包状态一致不处理
|
| | | if (oldHongBao.getState().intValue() == hongBao.getState())
|
| | | return;
|
| | | return false;
|
| | |
|
| | | if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) {
|
| | | if (mianDan) {
|
| | |
| | | BigDecimal firstRate = hongBaoManageService
|
| | | .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
|
| | | if (firstRate.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | return true;
|
| | | HongBaoV2 firstHongbao = new HongBaoV2();
|
| | | firstHongbao.setUserInfo(boss);
|
| | | firstHongbao.setUrank(boss.getRank());
|
| | |
| | | firstHongbao.setType(HongBaoV2.TYPE_YIJI);
|
| | | firstHongbao.setVersion(2);
|
| | | firstHongbao.setState(hongBao.getState());
|
| | | firstHongbao.setOrderType(commonOrder.getSourceType());
|
| | |
|
| | | if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | firstHongbao.setMoney(
|
| | |
| | | BigDecimal secondRate = hongBaoManageService
|
| | | .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
|
| | | if (secondRate.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | return true;
|
| | | HongBaoV2 secondHongbao = new HongBaoV2();
|
| | | secondHongbao.setUserInfo(boss);
|
| | | secondHongbao.setUrank(boss.getRank());
|
| | |
| | | secondHongbao.setType(HongBaoV2.TYPE_ERJI);
|
| | | secondHongbao.setVersion(2);
|
| | | secondHongbao.setState(hongBao.getState());
|
| | | secondHongbao.setOrderType(commonOrder.getSourceType());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | secondHongbao.setMoney(MoneyBigDecimalUtil.mul(hongBao.getMoney(),
|
| | | secondRate.divide(new BigDecimal(100))));
|
| | |
| | | }
|
| | | } else
|
| | | throw new HongBaoException(2, "type错误");
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | @Transactional
|
| | |
| | | CommonOrderGoods goods = commonOrderGoodsMapper
|
| | | .selectByPrimaryKey(commonOrder.getCommonOrderGoods().getId());
|
| | | if (goods != null) {
|
| | |
|
| | | try {
|
| | | if (userSystemCouponService.updateCouponRecordUsed(commonOrder.getUserInfo().getId(),
|
| | | commonOrder.getOrderNo(), payMent, Long.parseLong(goods.getGoodsId())))
|
| | |
| | |
|
| | | UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
|
| | | hongBao.setUrank(user.getRank());
|
| | | hongBao.setOrderType(commonOrder.getSourceType());
|
| | | hongBaoV2Mapper.insertSelective(hongBao);
|
| | | // 添加红包与订单的映射
|
| | | HongBaoOrder hongBaoOrder = new HongBaoOrder();
|
| | |
| | | firstHongbao.setType(HongBaoV2.TYPE_YIJI);
|
| | | firstHongbao.setVersion(2);
|
| | | firstHongbao.setState(hongBao.getState());
|
| | | firstHongbao.setOrderType(commonOrder.getSourceType());
|
| | |
|
| | | if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | firstHongbao.setMoney(
|
| | |
| | | secondHongbao.setType(HongBaoV2.TYPE_ERJI);
|
| | | secondHongbao.setVersion(2);
|
| | | secondHongbao.setState(hongBao.getState());
|
| | | secondHongbao.setOrderType(commonOrder.getSourceType());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | secondHongbao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100))));
|
| | |
| | | UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
|
| | | hongBao.setUrank(user.getRank());
|
| | | hongBao.setUserInfo(user);
|
| | | hongBao.setOrderType(commonOrder.getSourceType());
|
| | | hongBaoV2Mapper.insertSelective(hongBao);
|
| | | // 插入红包与订单映射
|
| | | HongBaoOrder hongBaoOrder = new HongBaoOrder();
|
| | |
| | | child.setUrank(boss.getRank());
|
| | | child.setVersion(2);
|
| | | child.setCreateTime(new Date());
|
| | | child.setOrderType(commonOrder.getSourceType());
|
| | | if (child.getMoney().compareTo(new BigDecimal(0)) > 0) {
|
| | | hongBaoV2Mapper.insertSelective(child);
|
| | | // 添加通知
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<HongBaoV2> listChildrenByIds(List<Long> idList) {
|
| | | if (idList == null || idList.size() == 0)
|
| | | return null;
|
| | | return hongBaoV2Mapper.listChildrenByIds(idList);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Long> getUidByNear30DayShareSucceed() {
|
| | | return hongBaoV2Mapper.getUidByNear30DayShareSucceed();
|
| | | }
|
| | |
| | | return hongBaoV2List.get(0);
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<HongBaoV2> listByIds(List<Long> idList) {
|
| | | return hongBaoV2Mapper.listByIds(idList);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.concurrent.ConcurrentHashMap;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.order.InviteOrderSubsidyMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMapService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | |
| | | @Resource
|
| | | private InviteOrderSubsidyMapper inviteOrderSubsidyMapper;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMapService orderHongBaoMapService;
|
| | |
|
| | | @Resource
|
| | | private OrderService orderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Override
|
| | | public InviteOrderSubsidy getByOrderNoAndType(Long uid, String orderNo, Integer type) {
|
| | | return inviteOrderSubsidyMapper.getByOrderNoAndType(uid, orderNo, type);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public InviteOrderSubsidy getByOrderNoAndTypeForUpdate(Long uid, String orderNo, Integer type) {
|
| | | return inviteOrderSubsidyMapper.getByOrderNoAndTypeForUpdate(uid, orderNo, type);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | |
| | | InviteOrderSubsidy old = getByOrderNoAndType(orderSubsidy.getUid(), orderSubsidy.getOrderNo(),
|
| | | orderSubsidy.getSourceType());
|
| | | if (old != null) {// 修改
|
| | | if (old.getState() == InviteOrderSubsidy.STATE_INVALID
|
| | | || old.getState() == InviteOrderSubsidy.STATE_SUBSIDIZED)
|
| | | return;
|
| | |
|
| | | // 修改状态
|
| | | InviteOrderSubsidy update = new InviteOrderSubsidy(old.getId());
|
| | | update.setMoney(orderSubsidy.getMoney());
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void addOrUpdateByOrder(String orderId, int sourceType) throws InviteOrderSubsidyException {
|
| | | List<HongBaoOrder> list = hongBaoOrderService.listByOrderIdAndSourceType(orderId, sourceType);
|
| | | if (list != null && list.size() > 0) {
|
| | | // 必须是自购订单才返利
|
| | | HongBaoV2 parent = hongBaoV2Service.selectByPrimaryKey(list.get(0).getHongBaoV2().getId());
|
| | | if (parent != null && parent.getType() == HongBaoV2.TYPE_ZIGOU) {
|
| | | Order order = orderService.findOrderByOrderIdAndType(orderId, sourceType);
|
| | | List<Long> idList = new ArrayList<>();
|
| | | for (HongBaoOrder ho : list)
|
| | | if (ho.getHongBaoV2() != null)
|
| | | idList.add(ho.getHongBaoV2().getId());
|
| | | // 查询子红包
|
| | | List<HongBaoV2> children = hongBaoV2Service.listChildrenByIds(idList);
|
| | | if (children != null && children.size() > 0) {
|
| | | Map<Long, Integer> uidHongBaoMap = new ConcurrentHashMap<>();
|
| | | for (HongBaoV2 v2 : children) {// 按用户ID统计红包
|
| | | Long uid = v2.getUserInfo().getId();
|
| | | if (v2.getState() == HongBaoV2.STATE_BUKELINGQU || v2.getState() == HongBaoV2.STATE_KELINGQU
|
| | | || v2.getState() == HongBaoV2.STATE_YILINGQU) {
|
| | | uidHongBaoMap.put(uid, v2.getType());
|
| | | }
|
| | | }
|
| | |
|
| | | List<HongBaoV2> hbList = hongBaoV2Service.listByIds(idList);
|
| | | int state = InviteOrderSubsidy.STATE_UNKNOWN;
|
| | | // 确定是否使用了奖励券
|
| | | if (orderHongBaoMapService.selectByOrderIdAndSourceType(orderId, sourceType) != null) {
|
| | | state = InviteOrderSubsidy.STATE_INVALID;
|
| | | } else {
|
| | | // 确定是否返利到账5天后
|
| | | if (recieveMoneyMoreThan(hbList, 5)) {
|
| | | state = InviteOrderSubsidy.STATE_VALID;
|
| | | } else {
|
| | | state = InviteOrderSubsidy.STATE_UNKNOWN;
|
| | | }
|
| | | }
|
| | |
|
| | | BigDecimal totalMoney = new BigDecimal(0);
|
| | | // 计算总返利
|
| | | for (HongBaoV2 v2 : hbList) {
|
| | | if (v2.getState() == HongBaoV2.STATE_BUKELINGQU || v2.getState() == HongBaoV2.STATE_KELINGQU
|
| | | || v2.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | totalMoney = totalMoney.add(v2.getMoney());
|
| | | }
|
| | |
|
| | | BigDecimal firstRate = hongBaoManageService
|
| | | .getInviteFirstLevelSubsidyRate(order.getThirdCreateTime().getTime());
|
| | | BigDecimal secondRate = hongBaoManageService
|
| | | .getInviteSecondLevelSubsidyRate(order.getThirdCreateTime().getTime());
|
| | |
|
| | | // 计算奖励金
|
| | | for (Iterator<Long> its = uidHongBaoMap.keySet().iterator(); its.hasNext();) {
|
| | | Long uid = its.next();
|
| | | int type = uidHongBaoMap.get(uid);
|
| | | if (type == HongBaoV2.TYPE_YIJI || type == HongBaoV2.TYPE_ERJI) {
|
| | | BigDecimal rate = null;
|
| | | if (type == HongBaoV2.TYPE_YIJI)
|
| | | rate = firstRate;
|
| | | else
|
| | | rate = secondRate;
|
| | | BigDecimal money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(totalMoney, rate),
|
| | | new BigDecimal(100));
|
| | | InviteOrderSubsidy orderSubsidy = new InviteOrderSubsidy();
|
| | | orderSubsidy.setMoney(money);
|
| | | orderSubsidy.setUid(uid);
|
| | | orderSubsidy.setOrderNo(orderId);
|
| | | orderSubsidy.setSourceType(sourceType);
|
| | | orderSubsidy.setState(state);
|
| | | addOrderSubsidy(orderSubsidy);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | private boolean recieveMoneyMoreThan(List<HongBaoV2> hbList, int day) {
|
| | | // 是否全部是到账状态或失效状态
|
| | | int invalidCount = 0;// 失效个数
|
| | | int recieveCount = 0;// 到账的个数
|
| | | long maxGetTime = 0;
|
| | | for (HongBaoV2 v2 : hbList) {
|
| | | if (v2.getState() == HongBaoV2.STATE_SHIXIAO)
|
| | | invalidCount++;
|
| | | else if (v2.getState() == HongBaoV2.STATE_YILINGQU) {
|
| | | recieveCount++;
|
| | | if (v2.getGetTime() != null && v2.getGetTime().getTime() > maxGetTime)
|
| | | maxGetTime = v2.getGetTime().getTime();
|
| | |
|
| | | }
|
| | | }
|
| | | if (invalidCount + recieveCount == hbList.size() && recieveCount > 0 && maxGetTime > 0) {// 全部已到账
|
| | | // 查询到账时间距离当前时间是否超过指定天
|
| | | if (System.currentTimeMillis() - maxGetTime > 1000 * 60 * 60 * 24L * day)
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countByOrderIdAndSourceType(String orderId, int sourceType) {
|
| | | return inviteOrderSubsidyMapper.countByOrderNoAndType(orderId, sourceType);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void invalidByOrderIdAndSourceType(String orderId, int sourceType) {
|
| | | List<InviteOrderSubsidy> list = inviteOrderSubsidyMapper.listByOrderNoAndType(orderId, sourceType);
|
| | | if (list != null && list.size() > 0)
|
| | | for (InviteOrderSubsidy subsidy : list) {
|
| | | if (subsidy.getState() == InviteOrderSubsidy.STATE_UNKNOWN
|
| | | || subsidy.getState() == InviteOrderSubsidy.STATE_VALID) {
|
| | | InviteOrderSubsidy update = new InviteOrderSubsidy(subsidy.getId());
|
| | | update.setState(InviteOrderSubsidy.STATE_INVALID);
|
| | | update.setUpdateTime(new Date());
|
| | | inviteOrderSubsidyMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void validByOrderIdAndSourceType(String orderId, int sourceType) {
|
| | | List<InviteOrderSubsidy> list = inviteOrderSubsidyMapper.listByOrderNoAndType(orderId, sourceType);
|
| | | if (list != null && list.size() > 0)
|
| | | for (InviteOrderSubsidy subsidy : list) {
|
| | | if (subsidy.getState() == InviteOrderSubsidy.STATE_UNKNOWN) {
|
| | | InviteOrderSubsidy update = new InviteOrderSubsidy(subsidy.getId());
|
| | | update.setState(InviteOrderSubsidy.STATE_VALID);
|
| | | update.setUpdateTime(new Date());
|
| | | inviteOrderSubsidyMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void settleById(Long id, BigDecimal money) {
|
| | | InviteOrderSubsidy orderSubsidy = new InviteOrderSubsidy(id);
|
| | | orderSubsidy.setMoney(money);
|
| | | orderSubsidy.setState(InviteOrderSubsidy.STATE_SUBSIDIZED);
|
| | | orderSubsidy.setUpdateTime(new Date());
|
| | | inviteOrderSubsidyMapper.updateByPrimaryKeySelective(orderSubsidy);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.order.OrderHongBaoMap;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMapService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | |
|
| | | @Service
|
| | | public class OrderHongBaoMapServiceImpl implements OrderHongBaoMapService {
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMapMapper orderHongBaoMapMapper;
|
| | |
|
| | | @Resource
|
| | | private OrderService orderService;
|
| | |
|
| | | @Override
|
| | | public void addOrderHongBaoMap(HongBaoV2 hongBao, Order order) {
|
| | |
| | | map.setOrder(order);
|
| | | orderHongBaoMapMapper.insertSelective(map);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public BigDecimal getCouponHongbaoByOrderNo(String orderNo, Long uid) {
|
| | | return orderHongBaoMapMapper.getCouponHongbaoByOrderNo(orderNo, uid);
|
| | | return orderHongBaoMapMapper.getCouponHongbaoByOrderNo(orderNo, uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public OrderHongBaoMap selectByOrderIdAndSourceType(String orderId, int sourceType) {
|
| | | Order order = orderService.findOrderByOrderIdAndType(orderId, sourceType);
|
| | | if (order != null) {
|
| | | List<OrderHongBaoMap> mapList = orderHongBaoMapMapper.listByOrderId(order.getId());
|
| | | if (mapList != null && mapList.size() > 0)
|
| | | return mapList.get(0);
|
| | | }
|
| | | return null;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.math.RoundingMode;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionProducer;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.mybatis.HongBaoV2Mapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.HongBaoOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.dto.HongBao;
|
| | | import com.yeshi.fanli.dto.order.OrderMoneyRecievedMQMsgDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoV2SettleTemp;
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.money.InviteOrderSubsidyDebtException;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.hongbao.AccountDetailsHongBaoMapService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2SettleTempService;
|
| | | import com.yeshi.fanli.service.inter.money.InviteOrderSubsidyDebtService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.money.tb.TaoBaoWeiQuanDrawBackService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderMoneySettleService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeOrderApiUtil;
|
| | |
|
| | | @Service
|
| | | public class OrderMoneySettleServiceImpl implements OrderMoneySettleService {
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2Mapper hongBaoV2Mapper;
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderMapper hongBaoOrderMapper;
|
| | |
|
| | | @Resource
|
| | | private UserInfoMapper userInfoMapper;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanDrawBackService taoBaoWeiQuanDrawBackService;
|
| | |
|
| | | @Resource
|
| | | private AccountDetailsHongBaoMapService accountDetailsHongBaoMapService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoOrderService taoBaoOrderService;
|
| | |
|
| | | @Resource(name = "orderTransactionProducer")
|
| | | private TransactionProducer orderTransactionProducer;
|
| | |
|
| | | // 邀请补贴
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyDebtService inviteOrderSubsidyDebtService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2SettleTempService hongBaoV2SettleTempService;
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void inviteSettleTB(Long uid) throws OrderMoneySettleException {
|
| | | // 查询UID的一二级邀请赚
|
| | | int sourceType = Constant.SOURCE_TYPE_TAOBAO;
|
| | | List<Integer> types = new ArrayList<>();
|
| | | types.add(HongBaoV2.TYPE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_ERJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | // 1000条数据为1页
|
| | | int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, sourceType,
|
| | | i * 1000, 1000);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
|
| | | for (int i = 0; i < hongBaoList.size(); i++) {
|
| | | HongBaoV2 item = hongBaoList.get(i);
|
| | | if (item != null && item.getParent() != null) {
|
| | | if (item != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(item.getParent().getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {
|
| | | CommonOrder co = hongBaoOrder.getCommonOrder();
|
| | | // 上级用户不是正常用户,订单均不能到账
|
| | | UserInfo userInfo = userInfoMapper.selectAvailableByPrimaryKey(co.getUserInfo().getId());
|
| | | if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) {
|
| | | hongBaoList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账事务消息
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_INVITE, uid,
|
| | | sourceType, null, null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | try {
|
| | | fanliInviteTB(hongBaoList, uid, taskKey);
|
| | | } catch (TaoBaoWeiQuanException e) {
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void inviteSettleJD(Long uid) throws OrderMoneySettleException {
|
| | | // 查询UID的一二级邀请赚
|
| | | int sourceType = Constant.SOURCE_TYPE_JD;
|
| | | List<Integer> types = new ArrayList<>();
|
| | | types.add(HongBaoV2.TYPE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_ERJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | // 1000条数据为1页
|
| | | int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, sourceType,
|
| | | i * 1000, 1000);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
|
| | | for (int i = 0; i < hongBaoList.size(); i++) {
|
| | | HongBaoV2 item = hongBaoList.get(i);
|
| | | if (item != null && item.getParent() != null) {
|
| | | if (item != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(item.getParent().getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {
|
| | | CommonOrder co = hongBaoOrder.getCommonOrder();
|
| | | // 上级用户不是正常用户,订单均不能到账
|
| | | UserInfo userInfo = userInfoMapper.selectAvailableByPrimaryKey(co.getUserInfo().getId());
|
| | | if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) {
|
| | | hongBaoList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账事务消息
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_INVITE, uid,
|
| | | sourceType, null, null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | fanliInviteOther(hongBaoList, uid, sourceType, taskKey);
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void inviteSettlePDD(Long uid) throws OrderMoneySettleException {
|
| | | // 查询UID的一二级邀请赚
|
| | | int sourceType = Constant.SOURCE_TYPE_PDD;
|
| | | List<Integer> types = new ArrayList<>();
|
| | | types.add(HongBaoV2.TYPE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_ERJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | // 1000条数据为1页
|
| | | int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, sourceType,
|
| | | i * 1000, 1000);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
|
| | | for (int i = 0; i < hongBaoList.size(); i++) {
|
| | | HongBaoV2 item = hongBaoList.get(i);
|
| | | if (item != null && item.getParent() != null) {
|
| | | if (item != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(item.getParent().getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {
|
| | | CommonOrder co = hongBaoOrder.getCommonOrder();
|
| | | // 上级用户不是正常用户,订单均不能到账
|
| | | UserInfo userInfo = userInfoMapper.selectAvailableByPrimaryKey(co.getUserInfo().getId());
|
| | | if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) {
|
| | | hongBaoList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账事务消息
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_INVITE, uid,
|
| | | sourceType, null, null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | fanliInviteOther(hongBaoList, uid, sourceType, taskKey);
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void shareSettleTB(Long uid) throws OrderMoneySettleException {
|
| | | /**
|
| | | * 处理分享赚
|
| | | */
|
| | | int sourceType = Constant.SOURCE_TYPE_TAOBAO;
|
| | | List<Integer> types = new ArrayList<>();
|
| | |
|
| | | // 查询UID的分享赚订单
|
| | | types.add(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | // 1000条数据为1页
|
| | | int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, sourceType,
|
| | | i * 1000, 1000);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_SHARE, uid,
|
| | | sourceType, null, null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | try {
|
| | | fanLiShareTB(hongBaoList, uid, taskKey);
|
| | | } catch (TaoBaoWeiQuanException e) {
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void shareSettleJD(Long uid) throws OrderMoneySettleException {
|
| | | /**
|
| | | * 处理分享赚
|
| | | */
|
| | | int sourceType = Constant.SOURCE_TYPE_JD;
|
| | | List<Integer> types = new ArrayList<>();
|
| | |
|
| | | // 查询UID的分享赚订单
|
| | | types.add(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | // 1000条数据为1页
|
| | | int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, sourceType,
|
| | | i * 1000, 1000);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_SHARE, uid,
|
| | | sourceType, null, null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | fanLiShareOther(hongBaoList, uid, sourceType, taskKey);
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void shareSettlePDD(Long uid) throws OrderMoneySettleException {
|
| | | /**
|
| | | * 处理分享赚
|
| | | */
|
| | | int sourceType = Constant.SOURCE_TYPE_PDD;
|
| | | List<Integer> types = new ArrayList<>();
|
| | |
|
| | | // 查询UID的分享赚订单
|
| | | types.add(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | // 1000条数据为1页
|
| | | int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, sourceType,
|
| | | i * 1000, 1000);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | |
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_SHARE, uid,
|
| | | sourceType, null, null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | String taskKey = getTaskKey(uid);
|
| | | msg.setKey(taskKey);
|
| | | // 添加事务消息
|
| | | try {
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | fanLiShareOther(hongBaoList, uid, sourceType, taskKey);
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void ziGouSettle(String orderId, int sourceType,String taskKey) throws OrderMoneySettleException {
|
| | | // 查询同一订单号的红包
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(sourceType, orderId);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | Map<Long, BigDecimal> userMoney = new HashMap<>();
|
| | | Map<Long, List<HongBaoV2>> userHongBao = new HashMap<>();
|
| | | Map<Long, Integer> userGoodsCount = new HashMap<>();
|
| | | for (CommonOrder co : orderList) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(co.getId());
|
| | | hongBaoList.add(hongBaoOrder.getHongBaoV2());
|
| | | Long uid = co.getUserInfo().getId();
|
| | | if (userGoodsCount.get(uid) == null)
|
| | | userGoodsCount.put(uid, co.getCount());
|
| | | else
|
| | | userGoodsCount.put(uid, Integer.valueOf(co.getCount() + userGoodsCount.get(uid)));
|
| | | }
|
| | |
|
| | | for (HongBaoV2 hb : hongBaoList) {
|
| | | long currentTimeMillis = System.currentTimeMillis();
|
| | | if (hb.getState() != HongBao.STATE_SHIXIAO) {
|
| | | // 设置为已返利
|
| | | // 处理主红包
|
| | | if (hb.getState() != HongBaoV2.STATE_SHIXIAO && hb.getState() != HongBaoV2.STATE_YILINGQU
|
| | | && hb.getType() == HongBaoV2.TYPE_ZIGOU) {
|
| | | // 如果红包没被领取
|
| | | Long uid = hb.getUserInfo().getId();
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hb.getId());
|
| | | updateHongBao.setState(HongBaoV2.STATE_YILINGQU);
|
| | | updateHongBao.setGetTime(new Date(currentTimeMillis));
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | if (userMoney.get(uid) == null)
|
| | | userMoney.put(uid, hb.getMoney());
|
| | | else
|
| | | userMoney.put(uid, userMoney.get(uid).add(hb.getMoney()));
|
| | |
|
| | | // 添加红包到用户
|
| | | if (userHongBao.get(uid) == null)
|
| | | userHongBao.put(uid, new ArrayList<>());
|
| | | userHongBao.get(uid).add(hb);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | Iterator<Long> its = userMoney.keySet().iterator();
|
| | |
|
| | | while (its.hasNext()) {
|
| | | // 将自己添加到用户
|
| | | Long uid = its.next();
|
| | | BigDecimal money = userMoney.get(uid);
|
| | | UserMoneyDetail userMoneyDetail = null;
|
| | | // 插入新版资金明细
|
| | | try {
|
| | | // 此处不用订单号做唯一性索引
|
| | | userMoneyDetail = UserMoneyDetailFactory.createFanLi(uid, orderId, sourceType, null, money);
|
| | | } catch (UserMoneyDetailException e1) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e1, "订单号:" + orderId, "");
|
| | | } catch (Exception e2) {
|
| | | e2.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | userMoneyService.addUserMoney(uid, money, userMoneyDetail);
|
| | | |
| | | List<Long> hbIdList=new ArrayList<>();
|
| | | // 添加资金明细与红包的映射关系
|
| | | for (HongBaoV2 v2 : userHongBao.get(uid)) {
|
| | | hbIdList.add(v2.getId());
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(v2.getId(), userMoneyDetail.getId());
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(v2.getId());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | //添加结算映射
|
| | | hongBaoV2SettleTempService.addTemp(hbIdList, taskKey);
|
| | |
|
| | | // 站内信+推送
|
| | | UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.fanliOrderReceived(uid, orderId, sourceType, userGoodsCount.get(uid), money,
|
| | | user.getMyHongBao());
|
| | | }
|
| | | // 通知免单到账
|
| | | try {
|
| | | userSystemCouponService.updateStateByArrivalAccount(orderId);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 维权扣款(2018-08-05后开始实行)
|
| | |
|
| | | try {
|
| | | if (sourceType == Constant.SOURCE_TYPE_TAOBAO)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanFanli(orderId);
|
| | | } catch (TaoBaoWeiQuanException e) {
|
| | | if (e.getCode() == TaoBaoWeiQuanException.CODE_NEDD_UPDATE_ORDER) {
|
| | | List<TaoBaoOrder> olist = taoBaoOrderService.getTaoBaoOrderByOrderId(orderId);
|
| | | if (olist != null && olist.size() > 0) {
|
| | | long time = TimeUtil.convertToTimeTemp(olist.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss");
|
| | | olist = TaoKeOrderApiUtil.getTaoBaoCommonOrderList(time, time + 1000 * 2L, 1);
|
| | | if (olist != null && olist.size() > 0) {
|
| | | for (int i = 0; i < olist.size(); i++) {
|
| | | if (!olist.get(i).getOrderId().equalsIgnoreCase(orderId)) {// 删除无关订单
|
| | | olist.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | taoBaoOrderService.addTaoBaoOrderList(olist);
|
| | | }
|
| | | }
|
| | | } else
|
| | | throw new OrderMoneySettleException(e.getCode(), "维权处理出错:" + e.getMsg());
|
| | | }
|
| | | |
| | | //添加结算映射
|
| | | |
| | | |
| | | }
|
| | |
|
| | | private HongBaoV2 filterWeiQuanINGHongBao(HongBaoV2 hongBao) {
|
| | |
|
| | | long hbId = hongBao.getId();
|
| | | if (hongBao.getParent() != null) {
|
| | | hbId = hongBao.getParent().getId();
|
| | | }
|
| | |
|
| | | HongBaoOrder hongbaoOrder = hongBaoOrderMapper.selectByHongBaoId(hbId);
|
| | |
|
| | | if (hongbaoOrder == null)
|
| | | return null;
|
| | |
|
| | | List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hongbaoOrder.getCommonOrder().getOrderNo(), "维权创建");
|
| | |
|
| | | List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList1 = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hongbaoOrder.getCommonOrder().getOrderNo(), "等待处理");
|
| | | if ((taoBaoWeiQuanList != null && taoBaoWeiQuanList.size() > 0)
|
| | | || (taoBaoWeiQuanList1 != null && taoBaoWeiQuanList1.size() > 0)) {
|
| | | return null;
|
| | | }
|
| | | return hongBao;
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | private void fanliInviteTB(List<HongBaoV2> hongBaoList, Long uid, String key) throws TaoBaoWeiQuanException {
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | | BigDecimal invitemoney = new BigDecimal(0);
|
| | | Set<String> inviteOrders = new HashSet<>();
|
| | | int inviteGoodsCount = 0;
|
| | |
|
| | | // 需要判断退款的订单号
|
| | | Set<String> drawBackOrders = new HashSet<String>();
|
| | | for (HongBaoV2 hongBao : hongBaoList) {
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | |
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU || hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | invitemoney = invitemoney.add(hongBao.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBaoV2.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hongBao.getId());
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getParent().getId());
|
| | | inviteGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | inviteOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | |
|
| | | Date balanceTime = hongBaoOrder.getCommonOrder().getSettleTime();
|
| | | if (balanceTime != null
|
| | | && balanceTime.getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | if (!StringUtil.isNullOrEmpty(hongBaoOrder.getCommonOrder().getOrderNo()))
|
| | | drawBackOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账
|
| | | if (invitemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | |
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 查询邀请赚的有效订单,失效订单,维权订单
|
| | | Calendar ca = Calendar.getInstance();
|
| | | Date maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate);
|
| | | long weiQuanCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInvite(uid, Constant.SOURCE_TYPE_TAOBAO,
|
| | | (int) validCount, (int) weiQuanCount, invitemoney, new Date());
|
| | |
|
| | | // 增加资金
|
| | | userMoneyService.addUserMoney(uid, invitemoney, userMoneyDetail);
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.inviteOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, inviteOrders.size(),
|
| | | inviteGoodsCount, invitemoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | | for (String orderId : drawBackOrders)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanInvite(orderId);
|
| | | }
|
| | |
|
| | | try {
|
| | | hongBaoV2SettleTempService.addTemp(hbIdList, key);
|
| | | } catch (Exception e1) {
|
| | | throw new TaoBaoWeiQuanException(200, "插入返利临时表出错");
|
| | | }
|
| | |
|
| | | // 所有的返利到账红包ID
|
| | | for (Long hongBaoId : hbIdList) {
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | private void fanliInviteOther(List<HongBaoV2> hongBaoList, Long uid, int sourceType, String key) {
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | | BigDecimal invitemoney = new BigDecimal(0);
|
| | | Set<String> inviteOrders = new HashSet<>();
|
| | | int inviteGoodsCount = 0;
|
| | |
|
| | | // 需要判断退款的订单号
|
| | | for (HongBaoV2 hongBao : hongBaoList) {
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU || hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | invitemoney = invitemoney.add(hongBao.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBaoV2.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hongBao.getId());
|
| | |
|
| | | // 2018-08-05 过后的订单才处理维权
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getParent().getId());
|
| | | inviteGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | inviteOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账
|
| | | if (invitemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 查询邀请赚的有效订单,失效订单,维权订单
|
| | | Calendar ca = Calendar.getInstance();
|
| | | Date maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate);
|
| | | long weiQuanCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInvite(uid, sourceType, (int) validCount,
|
| | | (int) weiQuanCount, invitemoney, new Date());
|
| | |
|
| | | // 增加资金
|
| | | userMoneyService.addUserMoney(uid, invitemoney, userMoneyDetail);
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.inviteOrderReceived(uid, sourceType, inviteOrders.size(), inviteGoodsCount,
|
| | | invitemoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | | }
|
| | |
|
| | | hongBaoV2SettleTempService.addTemp(hbIdList, key);
|
| | |
|
| | | // 所有的返利到账红包ID
|
| | | for (Long hongBaoId : hbIdList) {
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 淘宝分享赚返利
|
| | | * |
| | | * @param hongBaoList
|
| | | * @param uid
|
| | | * @throws TaoBaoWeiQuanException
|
| | | */
|
| | | private void fanLiShareTB(List<HongBaoV2> hongBaoList, Long uid, String key) throws TaoBaoWeiQuanException {
|
| | | BigDecimal sharemoney = new BigDecimal(0);
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | | Set<String> drawBackOrders = new HashSet<String>();
|
| | | List<Long> recieveHongBaoIds = new ArrayList<>();
|
| | | int shareGoodsCount = 0;
|
| | | Set<String> shareOrders = new HashSet<>();
|
| | |
|
| | | for (HongBaoV2 hongBao : hongBaoList) {
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | |
|
| | | if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU || hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | sharemoney = sharemoney.add(hongBao.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBao.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hongBao.getId());
|
| | | // 2018-08-05 过后的订单才处理维权
|
| | | Date balanceTime = null;
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getId());
|
| | | if (hongBaoOrder != null) {
|
| | | balanceTime = hongBaoOrder.getCommonOrder().getSettleTime();
|
| | | shareGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | }
|
| | | shareOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | if (balanceTime != null
|
| | | && balanceTime.getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | drawBackOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 分享赚到账
|
| | | */
|
| | |
|
| | | if (sharemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 计算本月的有效订单,失效订单,维权订单
|
| | | Calendar ca = Calendar.getInstance();
|
| | |
|
| | | Date maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate);
|
| | | long weiQuanCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, Constant.SOURCE_TYPE_TAOBAO,
|
| | | (int) validCount, (int) weiQuanCount, sharemoney, new Date());
|
| | | // 添加资金
|
| | | userMoneyService.addUserMoney(uid, sharemoney, userMoneyDetail);
|
| | |
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | if (hbIdList.size() > 0)
|
| | | recieveHongBaoIds.addAll(hbIdList);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.shareOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, shareOrders.size(),
|
| | | shareGoodsCount, sharemoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | for (String orderId : drawBackOrders)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanShare(orderId);
|
| | | }
|
| | |
|
| | | hongBaoV2SettleTempService.addTemp(recieveHongBaoIds, key);
|
| | |
|
| | | // 所有的返利到账红包ID
|
| | | for (Long hongBaoId : recieveHongBaoIds) {
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 其他平台分享赚返利
|
| | | * |
| | | * @param hongBaoList
|
| | | * @param uid
|
| | | * @param sourceType
|
| | | */
|
| | | private void fanLiShareOther(List<HongBaoV2> hongBaoList, Long uid, int sourceType, String key) {
|
| | | BigDecimal sharemoney = new BigDecimal(0);
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | | List<Long> recieveHongBaoIds = new ArrayList<>();
|
| | | int shareGoodsCount = 0;
|
| | | Set<String> shareOrders = new HashSet<>();
|
| | |
|
| | | for (HongBaoV2 hongBao : hongBaoList) {
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | |
|
| | | if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU || hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | sharemoney = sharemoney.add(hongBao.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBao.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hongBao.getId());
|
| | | // 2018-08-05 过后的订单才处理维权
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getId());
|
| | | if (hongBaoOrder != null) {
|
| | | shareGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | }
|
| | | shareOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 分享赚到账
|
| | | */
|
| | |
|
| | | if (sharemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 计算本月的有效订单,失效订单,维权订单
|
| | | Calendar ca = Calendar.getInstance();
|
| | |
|
| | | Date maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate);
|
| | | long weiQuanCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, Constant.SOURCE_TYPE_TAOBAO,
|
| | | (int) validCount, (int) weiQuanCount, sharemoney, new Date());
|
| | | // 添加资金
|
| | | userMoneyService.addUserMoney(uid, sharemoney, userMoneyDetail);
|
| | |
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | if (hbIdList.size() > 0)
|
| | | recieveHongBaoIds.addAll(hbIdList);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.shareOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, shareOrders.size(),
|
| | | shareGoodsCount, sharemoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | }
|
| | |
|
| | | hongBaoV2SettleTempService.addTemp(recieveHongBaoIds, key);
|
| | |
|
| | | // 所有的返利到账红包ID
|
| | | for (Long hongBaoId : recieveHongBaoIds) {
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 邀请补贴结算
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | @Transactional
|
| | | @Override
|
| | | public void inviteSubsidySettle(Long uid, String taskKey) throws OrderMoneySettleException {
|
| | | // 查询key
|
| | | List<HongBaoV2SettleTemp> list = hongBaoV2SettleTempService.listByKey(taskKey);
|
| | | if (list != null && list.size() > 0) {
|
| | |
|
| | | Integer sourceType = null;
|
| | | List<InviteOrderSubsidy> subsidyList = new ArrayList<>();
|
| | | for (HongBaoV2SettleTemp temp : list) {
|
| | | Long hongBaoId = temp.getHongBaoId();
|
| | | HongBaoV2 hongBao = hongBaoV2Mapper.selectByPrimaryKey(hongBaoId);
|
| | | if (sourceType != null)
|
| | | sourceType = hongBao.getOrderType();
|
| | | if (hongBao.getParent() != null)
|
| | | hongBao = hongBao.getParent();
|
| | | HongBaoOrder order = hongBaoOrderMapper.selectByHongBaoId(hongBao.getId());
|
| | | if (order != null && order.getCommonOrder() != null) {
|
| | | InviteOrderSubsidy subSidy = inviteOrderSubsidyService.getByOrderNoAndTypeForUpdate(uid,
|
| | | order.getCommonOrder().getOrderNo(), order.getCommonOrder().getSourceType());
|
| | | if (subSidy != null && subSidy.getState() == InviteOrderSubsidy.STATE_VALID) {
|
| | | subsidyList.add(subSidy);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (sourceType == null)
|
| | | throw new OrderMoneySettleException(1, "订单类型未获取到");
|
| | |
|
| | | if (subsidyList.size() > 0) {
|
| | | BigDecimal debtMoney = inviteOrderSubsidyDebtService.getTotalDebtMoney(uid);
|
| | | BigDecimal originalDebtMoney = new BigDecimal(debtMoney.toString());// 总的欠款
|
| | | List<InviteOrderSubsidy> copySubsidyList = new ArrayList<>();
|
| | | copySubsidyList.addAll(subsidyList);
|
| | | while (debtMoney.compareTo(new BigDecimal(0)) > 0 && copySubsidyList.size() > 0) {// 有欠款,还有还的
|
| | | debtMoney = kouKuan(copySubsidyList, debtMoney);
|
| | | }
|
| | | // 还款
|
| | | BigDecimal repayMoney = originalDebtMoney.subtract(debtMoney);
|
| | | BigDecimal bannce = null;
|
| | | if (repayMoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | try {
|
| | | bannce = inviteOrderSubsidyDebtService.repayDebtByUid(uid, repayMoney);
|
| | | // 剩余的补贴金额
|
| | | } catch (InviteOrderSubsidyDebtException e) {
|
| | | throw new OrderMoneySettleException(2, "还款异常");
|
| | | }
|
| | | }
|
| | | if (bannce != null && bannce.compareTo(new BigDecimal(0)) > 0) {
|
| | | // 如果有还剩下的钱就加到第一个上面
|
| | | subsidyList.get(0).setMoney(subsidyList.get(0).getMoney().add(bannce));
|
| | | }
|
| | |
|
| | | BigDecimal totalMoney = new BigDecimal(0);
|
| | | for (InviteOrderSubsidy subsidy : subsidyList) {
|
| | | inviteOrderSubsidyService.settleById(subsidy.getId(), subsidy.getMoney());
|
| | | totalMoney = totalMoney.add(subsidy.getMoney());
|
| | | }
|
| | |
|
| | | // 到账
|
| | | UserMoneyDetail userMoneyDetail = null;
|
| | | try {
|
| | | userMoneyDetail = UserMoneyDetailFactory.createInviteSubsidy(uid, sourceType, totalMoney,
|
| | | new Date());
|
| | | } catch (UserMoneyDetailException e) {
|
| | | throw new OrderMoneySettleException(1, "账户明细构建出错");
|
| | | }
|
| | | // 添加资金
|
| | | userMoneyService.addUserMoney(uid, totalMoney, userMoneyDetail);
|
| | | // TODO 添加消息
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private String getTaskKey(Long uid) {
|
| | | return uid + "-" + UUID.randomUUID().toString();
|
| | | }
|
| | |
|
| | | private BigDecimal kouKuan(List<InviteOrderSubsidy> subsidyList, BigDecimal debtMoney) {
|
| | | BigDecimal average = debtMoney.divide(new BigDecimal(subsidyList.size()), 2, RoundingMode.UP);
|
| | | for (int i = 0; i < subsidyList.size(); i++) {
|
| | | InviteOrderSubsidy sidy = subsidyList.get(i);
|
| | | BigDecimal subMoney = null;
|
| | | if (average.compareTo(sidy.getMoney()) >= 0) {
|
| | | subMoney = sidy.getMoney();
|
| | | } else {
|
| | | subMoney = average;
|
| | | }
|
| | | if (subMoney.compareTo(debtMoney) > 0)
|
| | | subMoney = debtMoney;
|
| | | debtMoney = debtMoney.subtract(subMoney);
|
| | | sidy.setMoney(sidy.getMoney().subtract(subMoney));
|
| | |
|
| | | if (sidy.getMoney().compareTo(new BigDecimal(0)) == 0) {
|
| | | subsidyList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | return debtMoney;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | |
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionProducer;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.mybatis.HongBaoV2Mapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.order.HongBaoOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.OrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.dto.HongBao;
|
| | | import com.yeshi.fanli.dto.order.CommonOrderAddResultDTO;
|
| | | import com.yeshi.fanli.dto.order.OrderMQMsgDTO;
|
| | | import com.yeshi.fanli.dto.order.OrderMoneyRecievedMQMsgDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanDrawBack;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.exception.order.HongBaoException;
|
| | |
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.LostOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderMoneySettleService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService;
|
| | | import com.yeshi.fanli.service.inter.order.jd.JDOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.pdd.PDDOrderService;
|
| | |
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.PlaceOrderCMQManager;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeOrderApiUtil;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTagConstant;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | @Service
|
| | | public class OrderProcessServiceImpl implements OrderProcessService {
|
| | |
| | |
|
| | | @Resource
|
| | | private PDDOrderService pddOrderService;
|
| | |
|
| | | @Resource(name = "orderTransactionProducer")
|
| | | private TransactionProducer orderTransactionProducer;
|
| | |
|
| | | @Resource
|
| | | private OrderMoneySettleService orderMoneySettleService;
|
| | |
|
| | | /**
|
| | | * 是否是分享订单
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | if (hongBaoOrder.getCommonOrder() == null) {// ||
|
| | | // hongBaoOrder.getCommonOrder().getSourceType()
|
| | | // ==
|
| | | // Constant.SOURCE_TYPE_JD
|
| | | // || hongBaoOrder.getCommonOrder().getSourceType() ==
|
| | | // Constant.SOURCE_TYPE_PDD
|
| | | if (hongBaoOrder.getCommonOrder() == null) {
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | // 查询同一订单号的红包
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(
|
| | | hongBaoOrder.getCommonOrder().getSourceType(), hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | Map<Long, BigDecimal> userMoney = new HashMap<>();
|
| | | Map<Long, List<HongBaoV2>> userHongBao = new HashMap<>();
|
| | | Map<Long, Integer> userGoodsCount = new HashMap<>();
|
| | | // Map<Long, BigDecimal> userPayMent = new HashMap<>();
|
| | | for (CommonOrder co : orderList) {
|
| | | hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(co.getId());
|
| | | hongBaoList.add(hongBaoOrder.getHongBaoV2());
|
| | | Long uid = co.getUserInfo().getId();
|
| | | if (userGoodsCount.get(uid) == null)
|
| | | userGoodsCount.put(uid, co.getCount());
|
| | | else
|
| | | userGoodsCount.put(uid, Integer.valueOf(co.getCount() + userGoodsCount.get(uid)));
|
| | | // if (userPayMent.get(uid) == null)
|
| | | // userPayMent.put(uid, new BigDecimal(0));
|
| | | // if (co.getState() == CommonOrder.STATE_JS)
|
| | | // userPayMent.put(uid,
|
| | | // userPayMent.get(uid).add(co.getSettlement()));
|
| | | // else
|
| | | // userPayMent.put(uid, userPayMent.get(uid).add(co.getPayment()));
|
| | | }
|
| | |
|
| | | for (HongBaoV2 hb : hongBaoList) {
|
| | | long currentTimeMillis = System.currentTimeMillis();
|
| | | if (hb.getState() != HongBao.STATE_SHIXIAO) {
|
| | | // 设置为已返利
|
| | | // 处理主红包
|
| | | if (hb.getState() != HongBaoV2.STATE_SHIXIAO && hb.getState() != HongBaoV2.STATE_YILINGQU
|
| | | && hb.getType() == HongBaoV2.TYPE_ZIGOU) {
|
| | | // 如果红包没被领取
|
| | | Long uid = hb.getUserInfo().getId();
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hb.getId());
|
| | | updateHongBao.setState(HongBaoV2.STATE_YILINGQU);
|
| | | updateHongBao.setGetTime(new Date(currentTimeMillis));
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | if (userMoney.get(uid) == null)
|
| | | userMoney.put(uid, hb.getMoney());
|
| | | else
|
| | | userMoney.put(uid, userMoney.get(uid).add(hb.getMoney()));
|
| | |
|
| | | // 添加红包到用户
|
| | | if (userHongBao.get(uid) == null)
|
| | | userHongBao.put(uid, new ArrayList<>());
|
| | | userHongBao.get(uid).add(hb);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | Iterator<Long> its = userMoney.keySet().iterator();
|
| | |
|
| | | while (its.hasNext()) {
|
| | | // 将自己添加到用户
|
| | | Long uid = its.next();
|
| | | BigDecimal money = userMoney.get(uid);
|
| | | UserMoneyDetail userMoneyDetail = null;
|
| | | // 插入新版资金明细
|
| | | try {
|
| | | // 此处不用订单号做唯一性索引
|
| | | userMoneyDetail = UserMoneyDetailFactory.createFanLi(uid, hongBaoOrder.getCommonOrder().getOrderNo(),
|
| | | hongBaoOrder.getCommonOrder().getSourceType(), null, money);
|
| | | } catch (UserMoneyDetailException e1) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e1, "订单号:" + hongBaoOrder.getCommonOrder().getOrderNo(), "");
|
| | | } catch (Exception e2) {
|
| | | e2.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | userMoneyService.addUserMoney(uid, money, userMoneyDetail);
|
| | | // 添加资金明细与红包的映射关系
|
| | | for (HongBaoV2 v2 : userHongBao.get(uid)) {
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(v2.getId(), userMoneyDetail.getId());
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(v2.getId());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | // 站内信+推送
|
| | | UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.fanliOrderReceived(uid, hongBaoOrder.getCommonOrder().getOrderNo(),
|
| | | hongBaoOrder.getCommonOrder().getSourceType(), userGoodsCount.get(uid), money, user.getMyHongBao());
|
| | | }
|
| | | // 通知免单到账
|
| | | // 自购到账事务消息
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_ZIGOU,
|
| | | mainUser.getId(), hongBaoOrder.getCommonOrder().getSourceType(),
|
| | | hongBaoOrder.getCommonOrder().getOrderNo(), null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | String key = mainUser.getId() + "-" + UUID.randomUUID().toString();
|
| | | msg.setKey(key);
|
| | | try {
|
| | | userSystemCouponService.updateStateByArrivalAccount(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 维权扣款(2018-08-05后开始实行)
|
| | | if (hongBaoOrder.getCommonOrder().getSettleTime() != null && hongBaoOrder.getCommonOrder().getSettleTime()
|
| | | .getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | try {
|
| | | if (hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_TAOBAO)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanFanli(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | } catch (TaoBaoWeiQuanException e) {
|
| | | if (e.getCode() == TaoBaoWeiQuanException.CODE_NEDD_UPDATE_ORDER) {
|
| | | List<TaoBaoOrder> olist = taoBaoOrderService
|
| | | .getTaoBaoOrderByOrderId(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | |
|
| | | if (olist != null && olist.size() > 0) {
|
| | | long time = TimeUtil.convertToTimeTemp(olist.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss");
|
| | | olist = TaoKeOrderApiUtil.getTaoBaoCommonOrderList(time, time + 1000 * 2L, 1);
|
| | | if (olist != null && olist.size() > 0) {
|
| | | for (int i = 0; i < olist.size(); i++) {
|
| | | if (!olist.get(i).getOrderId()
|
| | | .equalsIgnoreCase(hongBaoOrder.getCommonOrder().getOrderNo())) {// 删除无关订单
|
| | | olist.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | |
|
| | | taoBaoOrderService.addTaoBaoOrderList(olist);
|
| | | }
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | try {
|
| | | orderMoneySettleService.ziGouSettle(hongBaoOrder.getCommonOrder().getOrderNo(),
|
| | | hongBaoOrder.getCommonOrder().getSourceType(), key);
|
| | | return TransactionStatus.CommitTransaction;
|
| | | } catch (Exception e) {
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | } else
|
| | | throw new TaoBaoWeiQuanException(e.getCode(), e.getMsg());
|
| | | }
|
| | | }
|
| | | }, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | private HongBaoV2 filterWeiQuanINGHongBao(HongBaoV2 hongBao) {
|
| | |
|
| | | long hbId = hongBao.getId();
|
| | | if (hongBao.getParent() != null) {
|
| | | hbId = hongBao.getParent().getId();
|
| | | }
|
| | |
|
| | | HongBaoOrder hongbaoOrder = hongBaoOrderMapper.selectByHongBaoId(hbId);
|
| | |
|
| | | if (hongbaoOrder == null)
|
| | | return null;
|
| | |
|
| | | List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hongbaoOrder.getCommonOrder().getOrderNo(), "维权创建");
|
| | |
|
| | | List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList1 = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hongbaoOrder.getCommonOrder().getOrderNo(), "等待处理");
|
| | | if ((taoBaoWeiQuanList != null && taoBaoWeiQuanList.size() > 0)
|
| | | || (taoBaoWeiQuanList1 != null && taoBaoWeiQuanList1.size() > 0)) {
|
| | | return null;
|
| | | }
|
| | | return hongBao;
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void fanliInvaiteAndShare(Long uid) throws TaoBaoWeiQuanException {
|
| | | List<Long> recieveHongBaoIds = new ArrayList<>();
|
| | | /**
|
| | | * 处理邀请赚订单
|
| | | */
|
| | | // 查询UID的邀请赚订单
|
| | | List<Integer> types = new ArrayList<>();
|
| | | types.add(HongBaoV2.TYPE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_ERJI);
|
| | | long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid);
|
| | | List<HongBaoV2> hongBaoList = new ArrayList<>();
|
| | | // 1000条数据为1页
|
| | | int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1);
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, i * 1000,
|
| | | 1000);
|
| | | if (tempHongBaoList != null && tempHongBaoList.size() > 0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | | // 灰度测试中,京东/拼多多订单分享/邀请订单不返利
|
| | | for (int i = 0; i < hongBaoList.size(); i++) {
|
| | | HongBaoV2 item = hongBaoList.get(i);
|
| | | if (item.getType() == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | | } else {
|
| | | item = item.getParent();
|
| | | }
|
| | | if (item != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(item.getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {
|
| | | CommonOrder co = hongBaoOrder.getCommonOrder();
|
| | | // 上级用户不是正常用户,订单均不能到账
|
| | | UserInfo userInfo = userInfoMapper.selectAvailableByPrimaryKey(co.getUserInfo().getId());
|
| | | if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) {
|
| | | hongBaoList.remove(i);
|
| | | i--;
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | |
|
| | | BigDecimal invitemoney = new BigDecimal(0);
|
| | | Set<String> inviteOrders = new HashSet<>();
|
| | | int inviteGoodsCount = 0;
|
| | |
|
| | | // 需要判断退款的订单号
|
| | | Set<String> drawBackOrders = new HashSet<String>();
|
| | | for (HongBaoV2 hongBao : hongBaoList) {
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | |
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU || hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | invitemoney = invitemoney.add(hongBao.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBaoV2.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hongBao.getId());
|
| | |
|
| | | // 2018-08-05 过后的订单才处理维权
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getParent().getId());
|
| | | inviteGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | inviteOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | |
|
| | | Date balanceTime = hongBaoOrder.getCommonOrder().getSettleTime();
|
| | | if (balanceTime != null
|
| | | && balanceTime.getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | if (!StringUtil.isNullOrEmpty(hongBaoOrder.getCommonOrder().getOrderNo()))
|
| | | drawBackOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理一级二级分享赚(属于邀请赚类型)
|
| | | */
|
| | |
|
| | | List<HongBaoV2> totalHongBaoList = new ArrayList<>();
|
| | | // 查询UID的二级或者三级分享赚订单
|
| | | // TODO 暂时查询10000条数据,后面再做分页
|
| | | types.clear();
|
| | | types.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | // TODO 需要处理超过1w条数据的订单
|
| | | List<HongBaoV2> hbList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 0, 10000);
|
| | |
|
| | | if (hbList != null && hbList.size() > 0)
|
| | | totalHongBaoList.addAll(hbList);
|
| | |
|
| | | for (HongBaoV2 hb : totalHongBaoList) {
|
| | | if (hb.getState() == HongBaoV2.STATE_BUKELINGQU || hb.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | hb = filterWeiQuanINGHongBao(hb);
|
| | | if (hb == null)
|
| | | continue;
|
| | | invitemoney = invitemoney.add(hb.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hb.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBaoV2.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hb.getId());
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hb.getParent().getId());
|
| | | inviteGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | inviteOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | if (!StringUtil.isNullOrEmpty(hongBaoOrder.getCommonOrder().getOrderNo()))
|
| | | drawBackOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请赚到账
|
| | | if (invitemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | |
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 查询邀请赚的有效订单,失效订单,维权订单
|
| | | Calendar ca = Calendar.getInstance();
|
| | | Date maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate);
|
| | | long weiQuanCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInvite(uid, Constant.SOURCE_TYPE_TAOBAO,
|
| | | (int) validCount, (int) weiQuanCount, invitemoney, new Date());
|
| | |
|
| | | // 增加资金
|
| | | userMoneyService.addUserMoney(uid, invitemoney, userMoneyDetail);
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.inviteOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, inviteOrders.size(),
|
| | | inviteGoodsCount, invitemoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | for (String orderId : drawBackOrders)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanInvite(orderId);
|
| | | }
|
| | | if (hbIdList.size() > 0)
|
| | | recieveHongBaoIds.addAll(hbIdList);
|
| | | hbIdList.clear();
|
| | | drawBackOrders.clear();
|
| | |
|
| | | /**
|
| | | * 处理分享赚
|
| | | */
|
| | |
|
| | | int shareGoodsCount = 0;
|
| | | Set<String> shareOrders = new HashSet<>();
|
| | | BigDecimal sharemoney = new BigDecimal(0);
|
| | | // 查询UID的分享赚订单
|
| | | types.clear();
|
| | | types.add(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | // TODO 需要处理超过10000条数据的订单
|
| | | List<HongBaoV2> hongBaoShareList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 0, 10000);
|
| | | for (HongBaoV2 hongBao : hongBaoShareList) {
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | | if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU || hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | sharemoney = sharemoney.add(hongBao.getMoney());
|
| | | HongBaoV2 updateHongBao = new HongBaoV2();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(new Date());
|
| | | updateHongBao.setState(HongBao.STATE_YILINGQU);
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 添加到红包返利记录集合
|
| | | hbIdList.add(hongBao.getId());
|
| | | // 2018-08-05 过后的订单才处理维权
|
| | | Date balanceTime = null;
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getId());
|
| | | if (hongBaoOrder != null) {
|
| | | balanceTime = hongBaoOrder.getCommonOrder().getSettleTime();
|
| | | shareGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | }
|
| | | shareOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | if (balanceTime != null
|
| | | && balanceTime.getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | drawBackOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | }
|
| | | }
|
| | | try {
|
| | | orderMoneySettleService.inviteSettleTB(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 分享赚到账
|
| | | */
|
| | |
|
| | | if (sharemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 计算本月的有效订单,失效订单,维权订单
|
| | | Calendar ca = Calendar.getInstance();
|
| | |
|
| | | Date maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate);
|
| | | long weiQuanCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate);
|
| | | long invalidCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_SX,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, Constant.SOURCE_TYPE_TAOBAO,
|
| | | (int) validCount, (int) weiQuanCount, sharemoney, new Date());
|
| | | // 添加资金
|
| | | userMoneyService.addUserMoney(uid, sharemoney, userMoneyDetail);
|
| | |
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | if (hbIdList.size() > 0)
|
| | | recieveHongBaoIds.addAll(hbIdList);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.shareOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, shareOrders.size(),
|
| | | shareGoodsCount, sharemoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | for (String orderId : drawBackOrders)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanShare(orderId);
|
| | | try {
|
| | | orderMoneySettleService.inviteSettleJD(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 所有的返利到账红包ID
|
| | | for (Long hongBaoId : recieveHongBaoIds) {
|
| | | try {
|
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
|
| | | try {
|
| | | orderMoneySettleService.inviteSettlePDD(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 分享赚到账
|
| | | try {
|
| | | orderMoneySettleService.shareSettleTB(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | try {
|
| | | orderMoneySettleService.shareSettleJD(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | try {
|
| | | orderMoneySettleService.shareSettlePDD(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
| | |
| | | // 原来不存在订单
|
| | | Long uid = null;
|
| | | if (oldOrder == null) {
|
| | | PidUser pidUser = null;// pidUserMapper.selectByPid(pid);
|
| | | if (pidUser != null) {
|
| | | uid = pidUser.getUid();
|
| | | Long targetUid = null;
|
| | | if (pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)
|
| | | && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {
|
| | | targetUid = taoBaoBuyRelationMapService.selectUidByRelationId(orderList.get(0).getRelationId());
|
| | |
|
| | | } else if (!StringUtil.isNullOrEmpty(orderList.get(0).getSpecialId())) {
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService
|
| | | .getBySpecialId(orderList.get(0).getSpecialId());
|
| | | if (info != null && info.getUser() != null)
|
| | | targetUid = info.getUser().getId();
|
| | | }
|
| | |
|
| | | if (targetUid != null) {
|
| | | uid = targetUid;
|
| | | // 插入到Order中
|
| | | // 添加到订单中去
|
| | | Order order = new Order();
|
| | |
| | | // 加入到订单表
|
| | | orderMapper.insertSelective(order);
|
| | | oldOrder = order;
|
| | | } else {
|
| | | Long targetUid = null;
|
| | | if (pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)
|
| | | && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {
|
| | | targetUid = taoBaoBuyRelationMapService.selectUidByRelationId(orderList.get(0).getRelationId());
|
| | |
|
| | | } else if (!StringUtil.isNullOrEmpty(orderList.get(0).getSpecialId())) {
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService
|
| | | .getBySpecialId(orderList.get(0).getSpecialId());
|
| | | if (info != null && info.getUser() != null)
|
| | | targetUid = info.getUser().getId();
|
| | | }
|
| | |
|
| | | if (targetUid != null) {
|
| | | uid = targetUid;
|
| | | // 插入到Order中
|
| | | // 添加到订单中去
|
| | | Order order = new Order();
|
| | | order.setBeizhu("PID返利订单");
|
| | | order.setCreatetime(System.currentTimeMillis());
|
| | | order.setOrderId(orderId);
|
| | | order.setOrderType(1);
|
| | | order.setState(Order.STATE_YIZHIFU);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | order.setVersion(2);
|
| | | // 加入到订单表
|
| | | orderMapper.insertSelective(order);
|
| | | oldOrder = order;
|
| | | }
|
| | | }
|
| | |
|
| | | } else {
|
| | | uid = oldOrder.getUserInfo().getId();
|
| | | }
|
| | |
| | | List<CommonOrderAddResultDTO> commonOrderList = null;
|
| | | try {
|
| | | commonOrderList = commonOrderService.addTaoBaoOrder(orderList, uid);
|
| | | hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_ZIGOU);
|
| | |
|
| | | addHongBaoWithMQ(commonOrderList, orderId, uid, Constant.SOURCE_TYPE_TAOBAO, HongBaoV2.TYPE_ZIGOU);
|
| | | if (isCommonOrderAllAdd(commonOrderList)) {
|
| | | Order order = new Order();
|
| | | order.setOrderId(orderId);
|
| | |
| | |
|
| | | @Override
|
| | | public void processShareGoodsOrderNew(String orderId, List<TaoBaoOrder> orderList) {
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
|
| | | if (orderList != null && orderList.size() > 0) {
|
| | | String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(),
|
| | | orderList.get(0).getSourceMediaId(), orderList.get(0).getAdPositionId());
|
| | | // 原来不存在订单
|
| | | Long uid = null;
|
| | | PidUser pidUser = null; // pidUserMapper.selectByPid(pid);-PID机制移除
|
| | | if (pidUser != null)
|
| | | uid = pidUser.getUid();
|
| | | else {
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByRelationId(orderList.get(0).getRelationId());
|
| | | if (info != null && info.getUser() != null)
|
| | | uid = info.getUser().getId();
|
| | | }
|
| | |
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByRelationId(orderList.get(0).getRelationId());
|
| | | if (info != null && info.getUser() != null)
|
| | | uid = info.getUser().getId();
|
| | | // 尚未找到和PID对应的用户
|
| | | if (uid == null) {
|
| | | // 通过红包查询
|
| | |
| | | // 用第一个子订单锁定用户
|
| | | try {
|
| | | List<CommonOrderAddResultDTO> commonOrders = commonOrderService.addTaoBaoOrder(orderList, uid);
|
| | | hongBaoV2Service.addHongBao(convertCommonOrder(commonOrders), HongBaoV2.TYPE_SHARE_GOODS);
|
| | | addHongBaoWithMQ(commonOrders, orderId, uid, Constant.SOURCE_TYPE_TAOBAO, HongBaoV2.TYPE_SHARE_GOODS);
|
| | | if (isCommonOrderAllAdd(commonOrders)) {
|
| | | Order order = new Order();
|
| | | order.setOrderId(orderId);
|
| | |
| | | }
|
| | | } catch (CommonOrderException e) {
|
| | | e.printStackTrace();
|
| | | } catch (HongBaoException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | try {
|
| | | List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addJDOrder(jdOrder, uid);
|
| | | hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_ZIGOU);
|
| | | addHongBaoWithMQ(commonOrderList, jdOrder.getOrderId() + "", uid, Constant.SOURCE_TYPE_JD,
|
| | | HongBaoV2.TYPE_ZIGOU);
|
| | |
|
| | | if (isCommonOrderAllAdd(commonOrderList)) {
|
| | | Order order = new Order();
|
| | | order.setOrderId(jdOrder.getOrderId() + "");
|
| | | order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | order.setOrderType(Constant.SOURCE_TYPE_JD);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | |
| | | }
|
| | | }
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + jdOrder.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + jdOrder.getOrderId());
|
| | | } catch (Exception e1) {
|
| | |
| | | private void processShareJDOrder(JDOrder jdOrder, Long uid) {
|
| | | try {
|
| | | List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addJDOrder(jdOrder, uid);
|
| | | hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_SHARE_GOODS);
|
| | | addHongBaoWithMQ(commonOrderList, jdOrder.getOrderId() + "", uid, Constant.SOURCE_TYPE_JD,
|
| | | HongBaoV2.TYPE_SHARE_GOODS);
|
| | | if (isCommonOrderAllAdd(commonOrderList)) {
|
| | | Order order = new Order();
|
| | | order.setOrderId(jdOrder.getOrderId() + "");
|
| | | order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | order.setOrderType(Constant.SOURCE_TYPE_JD);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | |
| | | }
|
| | | }
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + jdOrder.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + jdOrder.getOrderId());
|
| | | } catch (Exception e1) {
|
| | |
| | | List<PDDOrder> pddOrderList = new ArrayList<>();
|
| | | pddOrderList.add(pddOrder);
|
| | | List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
|
| | | hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_ZIGOU);
|
| | | addHongBaoWithMQ(commonOrderList, pddOrder.getOrderSn(), uid, Constant.SOURCE_TYPE_PDD,
|
| | | HongBaoV2.TYPE_ZIGOU);
|
| | | if (isCommonOrderAllAdd(commonOrderList)) {
|
| | | Order order = new Order();
|
| | | order.setOrderId(pddOrder.getOrderSn());
|
| | | order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | order.setOrderType(Constant.SOURCE_TYPE_PDD);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | |
| | | }
|
| | | }
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addPDDOrder或addHongBao出错", "订单号:" + pddOrder.getOrderSn());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addPDDOrder或addHongBao出错", "订单号:" + pddOrder.getOrderSn());
|
| | | } catch (Exception e1) {
|
| | |
| | | List<PDDOrder> pddOrderList = new ArrayList<>();
|
| | | pddOrderList.add(pddOrder);
|
| | | List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
|
| | | hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_SHARE_GOODS);
|
| | | addHongBaoWithMQ(commonOrderList, pddOrder.getOrderSn(), uid, Constant.SOURCE_TYPE_PDD,
|
| | | HongBaoV2.TYPE_SHARE_GOODS);
|
| | | if (isCommonOrderAllAdd(commonOrderList)) {
|
| | | Order order = new Order();
|
| | | order.setOrderId(pddOrder.getOrderSn());
|
| | | order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | order.setOrderType(Constant.SOURCE_TYPE_PDD);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | |
| | | }
|
| | | }
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + pddOrder.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + pddOrder.getOrderId());
|
| | | } catch (Exception e1) {
|
| | |
| | | public List<HongBaoV2> getCanBalanceElmeFanliHongBao() {
|
| | | List<Integer> list = new ArrayList<>();
|
| | | list.add(HongBaoV2.TYPE_ELME);
|
| | | return hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(list, null, 0, 1000);
|
| | | return hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(list, null, null, 0, 1000);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | // 返利到账
|
| | | }
|
| | |
|
| | | /**
|
| | | * 添加红包与事务消息
|
| | | * |
| | | * @param commonOrderList
|
| | | * @param orderId
|
| | | * @param uid
|
| | | * @param sourceType
|
| | | * @param hongBaoType
|
| | | */
|
| | | private void addHongBaoWithMQ(List<CommonOrderAddResultDTO> commonOrderList, String orderId, Long uid,
|
| | | int sourceType, int hongBaoType) {
|
| | | final List<CommonOrder> coList = convertCommonOrder(commonOrderList);
|
| | | OrderMQMsgDTO mqMsg = new OrderMQMsgDTO(orderId, sourceType, uid);
|
| | | Message msg = new Message(MQTopicName.TOPIC_ORDER.name(),
|
| | | String.format(MQTagConstant.TAG_ORDER_STATISTIC_PREFIX + "%s-%s", sourceType, hongBaoType),
|
| | | new Gson().toJson(mqMsg).getBytes());
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | int resultCode = 0;
|
| | | try {
|
| | | resultCode = hongBaoV2Service.addHongBao(coList, hongBaoType);
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + orderId);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | if (resultCode != 0)
|
| | | return TransactionStatus.CommitTransaction;
|
| | | else
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | }, null);
|
| | | }
|
| | | }
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getInviteFirstLevelSubsidyRate(Long time) {
|
| | | String key = "invite_subsidy_6";
|
| | | HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
|
| | | if (hongBaoManage == null)
|
| | | hongBaoManage = hongBaoManageMapper.selectByKey(key);
|
| | | if (hongBaoManage != null)
|
| | | return new BigDecimal(hongBaoManage.getValue());
|
| | | return new BigDecimal(0);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getInviteSecondLevelSubsidyRate(Long time) {
|
| | | String key = "invite_subsidy_7";
|
| | | HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
|
| | | if (hongBaoManage == null)
|
| | | hongBaoManage = hongBaoManageMapper.selectByKey(key);
|
| | | if (hongBaoManage != null)
|
| | | return new BigDecimal(hongBaoManage.getValue());
|
| | | return new BigDecimal(0);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.TransactionStatus;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.transaction.support.DefaultTransactionDefinition;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderTradeMapMapper;
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoOrderTradeMapMapper taoBaoOrderTradeMapMapper;
|
| | |
|
| | | @Resource(name = "transactionManager")
|
| | | private DataSourceTransactionManager transactionManager;
|
| | |
|
| | | /**
|
| | | * 获取订单的哈希值
|
| | |
| | | @Transactional
|
| | | @Override
|
| | | public void addTaoBaoOrder(String orderId, List<TaoBaoOrder> list) {
|
| | | LogHelper.test("订单号与订单数量:" + orderId + "-" + list.size());
|
| | | // 验证orderby是否正确
|
| | | if (list != null && list.size() > 0) {
|
| | | int maxOrderBy = list.get(0).getOrderBy();
|
| | | if (list.size() > 1)
|
| | | for (TaoBaoOrder order : list) {
|
| | | if (order.getOrderBy() > maxOrderBy)
|
| | | maxOrderBy = order.getOrderBy();
|
| | | TransactionStatus transactionStatus = transactionManager.getTransaction(new DefaultTransactionDefinition());
|
| | | try {
|
| | |
|
| | | LogHelper.test("订单号与订单数量:" + orderId + "-" + list.size());
|
| | | |
| | | // 验证orderby是否正确
|
| | | if (list != null && list.size() > 0) {
|
| | | int maxOrderBy = list.get(0).getOrderBy();
|
| | | if (list.size() > 1)
|
| | | for (TaoBaoOrder order : list) {
|
| | | if (order.getOrderBy() > maxOrderBy)
|
| | | maxOrderBy = order.getOrderBy();
|
| | | }
|
| | |
|
| | | if (list.size() != maxOrderBy) {
|
| | | LogHelper.test("捕捉到排序值错误:" + orderId);
|
| | | throw new Exception();
|
| | | }
|
| | |
|
| | | if (list.size() != maxOrderBy) {
|
| | | LogHelper.test("捕捉到排序值错误:" + orderId);
|
| | | return;
|
| | | }
|
| | | }
|
| | | // 验证tradeId问题
|
| | | Set<String> tradesIds = new HashSet<>();
|
| | | for (TaoBaoOrder order : list) {
|
| | | tradesIds.add(order.getTradeId());
|
| | | }
|
| | |
|
| | | // 有重复的交易ID不处理
|
| | | if (tradesIds.size() != list.size()) {
|
| | | LogHelper.test("检测到交易ID重复问题:" + orderId);
|
| | | return;
|
| | | }
|
| | |
|
| | | List<TaoBaoOrder> oldOrderList = taoBaoOrderMapper.selectTaoBaoOrderByOrderId(orderId);
|
| | | if (oldOrderList == null || oldOrderList.size() == 0) {
|
| | | for (TaoBaoOrder taoBaoOrder : list) {
|
| | | taoBaoOrder.setLatestUpdateTime(new Date());
|
| | | taoBaoOrderMapper.insertSelective(taoBaoOrder);
|
| | | addTaoBaoOrderTradeMap(taoBaoOrder);
|
| | | // 验证tradeId问题
|
| | | Set<String> tradesIds = new HashSet<>();
|
| | | for (TaoBaoOrder order : list) {
|
| | | tradesIds.add(order.getTradeId());
|
| | | }
|
| | | } else {
|
| | | if (StringUtil.isNullOrEmpty(oldOrderList.get(0).getTradeId())) {
|
| | | taoBaoOrderMapper.deleteByOrderId(orderId);
|
| | |
|
| | | // 有重复的交易ID不处理
|
| | | if (tradesIds.size() != list.size()) {
|
| | | LogHelper.test("检测到交易ID重复问题:" + orderId);
|
| | | throw new Exception();
|
| | | }
|
| | |
|
| | | List<TaoBaoOrder> oldOrderList = taoBaoOrderMapper.selectTaoBaoOrderByOrderId(orderId);
|
| | | if (oldOrderList == null || oldOrderList.size() == 0) {
|
| | | for (TaoBaoOrder taoBaoOrder : list) {
|
| | | taoBaoOrder.setLatestUpdateTime(new Date());
|
| | | taoBaoOrderMapper.insertSelective(taoBaoOrder);
|
| | | addTaoBaoOrderTradeMap(taoBaoOrder);
|
| | | }
|
| | | } else {
|
| | | // 按tradeId更新
|
| | | for (TaoBaoOrder taoBaoOrder : list) {
|
| | | TaoBaoOrder order = taoBaoOrderMapper.selectTaoBaoOrderByTradeId(taoBaoOrder.getTradeId());
|
| | | if (order == null) {
|
| | | if (StringUtil.isNullOrEmpty(oldOrderList.get(0).getTradeId())) {
|
| | | taoBaoOrderMapper.deleteByOrderId(orderId);
|
| | | for (TaoBaoOrder taoBaoOrder : list) {
|
| | | taoBaoOrder.setLatestUpdateTime(new Date());
|
| | | taoBaoOrderMapper.insertSelective(taoBaoOrder);
|
| | | addTaoBaoOrderTradeMap(taoBaoOrder);
|
| | | } else {
|
| | | taoBaoOrder.setId(order.getId());
|
| | | if (!StringUtil.isNullOrEmpty(order.getRelationId()))
|
| | | taoBaoOrder.setRelationId(order.getRelationId());
|
| | | if (!StringUtil.isNullOrEmpty(order.getSpecialId()))
|
| | | taoBaoOrder.setSpecialId(order.getSpecialId());
|
| | | taoBaoOrder.setLatestUpdateTime(new Date());
|
| | | taoBaoOrderMapper.updateByPrimaryKeySelective(taoBaoOrder);
|
| | | addTaoBaoOrderTradeMap(taoBaoOrder);
|
| | | }
|
| | | } else {
|
| | | // 按tradeId更新
|
| | | for (TaoBaoOrder taoBaoOrder : list) {
|
| | | TaoBaoOrder order = taoBaoOrderMapper.selectTaoBaoOrderByTradeId(taoBaoOrder.getTradeId());
|
| | | if (order == null) {
|
| | | taoBaoOrder.setLatestUpdateTime(new Date());
|
| | | taoBaoOrderMapper.insertSelective(taoBaoOrder);
|
| | | addTaoBaoOrderTradeMap(taoBaoOrder);
|
| | | } else {
|
| | | taoBaoOrder.setId(order.getId());
|
| | | if (!StringUtil.isNullOrEmpty(order.getRelationId()))
|
| | | taoBaoOrder.setRelationId(order.getRelationId());
|
| | | if (!StringUtil.isNullOrEmpty(order.getSpecialId()))
|
| | | taoBaoOrder.setSpecialId(order.getSpecialId());
|
| | | taoBaoOrder.setLatestUpdateTime(new Date());
|
| | | taoBaoOrderMapper.updateByPrimaryKeySelective(taoBaoOrder);
|
| | | addTaoBaoOrderTradeMap(taoBaoOrder);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | // 提交事务
|
| | | transactionManager.commit(transactionStatus);
|
| | | } catch (Exception e) {
|
| | | transactionManager.rollback(transactionStatus);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.entity.DateInfo;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionProducer;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserSystemCouponMapper;
|
| | | import com.yeshi.fanli.dto.msg.MsgOtherCouponActivateDTO;
|
| | | import com.yeshi.fanli.dto.msg.MsgOtherGiveContentDTO;
|
| | | import com.yeshi.fanli.dto.user.coupon.UserSystemCouponUseMQMsgDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail.MsgTypeOtherTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | |
| | | import com.yeshi.fanli.entity.system.SystemCoupon;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.exception.order.HongBaoException;
|
| | | import com.yeshi.fanli.exception.user.UserInfoExtraException;
|
| | | import com.yeshi.fanli.exception.user.UserSystemCouponException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | |
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.util.factory.msg.MsgOtherSystemGiveDTOFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTagConstant;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderVO;
|
| | |
| | |
|
| | | @Resource
|
| | | private TokenRecordService tokenRecordService;
|
| | |
|
| | | @Resource(name = "orderTransactionProducer")
|
| | | private TransactionProducer orderTransactionProducer;
|
| | |
|
| | | @Override
|
| | | public int insertSelective(UserSystemCoupon record) {
|
| | |
| | | if (systemCoupon == null)
|
| | | throw new UserSystemCouponException(1, "券已不存在");
|
| | | }
|
| | | |
| | |
|
| | | if (systemCoupon.getType() != CouponTypeEnum.rebatePercentCoupon)
|
| | | throw new UserSystemCouponException(1, "券类型不匹配");
|
| | |
|
| | |
| | | sourceType);
|
| | | if (orderVO == null)
|
| | | throw new UserSystemCouponException(1, "订单信息获取失败");
|
| | | |
| | |
|
| | | // 版本区分:2.0.2
|
| | | if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | Date thirdCreateTime = orderVO.getThirdCreateTime();
|
| | | if (thirdCreateTime != null) {
|
| | | long downOrderTime = thirdCreateTime.getTime();
|
| | | long limitDate = Long.parseLong("1573315200000"); // TODO 日期待确定2019-11-10
|
| | | long limitDate = Long.parseLong("1573315200000"); // TODO
|
| | | // 日期待确定2019-11-10
|
| | | if (downOrderTime > limitDate) {
|
| | | Date endDay = DateUtil.plusDayDate(4, thirdCreateTime);
|
| | | long currentTime = java.lang.System.currentTimeMillis();
|
| | |
| | | boolean valid = false;
|
| | | DateInfo dateInfo = DateUtil.dateDiff3(currentTime, endDay.getTime());
|
| | | if (dateInfo != null) {
|
| | | if (dateInfo.getDay() > 0) |
| | | if (dateInfo.getDay() > 0)
|
| | | valid = true;
|
| | |
|
| | | if (!valid && dateInfo.getHour() > 0)
|
| | | valid = true;
|
| | | |
| | |
|
| | | if (!valid && dateInfo.getMinute() > 0) |
| | | if (!valid && dateInfo.getMinute() > 0)
|
| | | valid = true;
|
| | | |
| | |
|
| | | if (!valid && dateInfo.getSecond() >= 0)
|
| | | valid = true;
|
| | | }
|
| | | |
| | | if (!valid) |
| | |
|
| | | if (!valid)
|
| | | throw new UserSystemCouponException(1, "该订单已不能使用使用奖励券,详情请咨询客服");
|
| | | }
|
| | | }
|
| | |
| | | // 提成金额
|
| | | BigDecimal money = MoneyBigDecimalUtil.mul(hongBao, percent);
|
| | |
|
| | | // 1、插入红包数据
|
| | | HongBaoV2 hongBaoV2 = new HongBaoV2();
|
| | | hongBaoV2.setMoney(money);
|
| | | hongBaoV2.setType(HongBaoV2.TYPE_COUPON);
|
| | | hongBaoV2.setState(HongBaoV2.STATE_YILINGQU);
|
| | | hongBaoV2.setVersion(2);
|
| | | hongBaoV2.setCreateTime(new Date());
|
| | | hongBaoV2.setUpdateTime(new Date());
|
| | | hongBaoV2.setUserInfo(new UserInfo(uid));
|
| | | hongBaoV2.setPreGetTime(new Date());
|
| | | hongBaoV2.setGetTime(new Date());
|
| | | UserSystemCouponUseMQMsgDTO mqMsg = new UserSystemCouponUseMQMsgDTO(userSystemCoupon.getId(),
|
| | | order.getOrderId(), sourceType);
|
| | | // 事务消息
|
| | | Message msg = new Message(MQTopicName.TOPIC_SYSTEM_COUPON_USE.name(),systemCoupon.getType().name(),
|
| | | new Gson().toJson(mqMsg).getBytes());
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | try {
|
| | | useRewardCouponCore(userSystemCoupon, money, hongBao, uid, order);
|
| | | return TransactionStatus.CommitTransaction;
|
| | | } catch (UserMoneyDetailException e) {
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | }
|
| | | }, null);
|
| | |
|
| | | hongBaoV2Service.insertSelective(hongBaoV2);
|
| | | }
|
| | | }
|
| | |
|
| | | // 2.插入关联
|
| | | orderHongBaoMapService.addOrderHongBaoMap(hongBaoV2, order);
|
| | | @Transactional
|
| | | private void useRewardCouponCore(UserSystemCoupon userSystemCoupon, BigDecimal money, BigDecimal hongBao, Long uid,
|
| | | Order order) throws UserMoneyDetailException {
|
| | | // 1、插入红包数据
|
| | | HongBaoV2 hongBaoV2 = new HongBaoV2();
|
| | | hongBaoV2.setMoney(money);
|
| | | hongBaoV2.setType(HongBaoV2.TYPE_COUPON);
|
| | | hongBaoV2.setState(HongBaoV2.STATE_YILINGQU);
|
| | | hongBaoV2.setVersion(2);
|
| | | hongBaoV2.setCreateTime(new Date());
|
| | | hongBaoV2.setUpdateTime(new Date());
|
| | | hongBaoV2.setUserInfo(new UserInfo(uid));
|
| | | hongBaoV2.setPreGetTime(new Date());
|
| | | hongBaoV2.setGetTime(new Date());
|
| | |
|
| | | // 3.插入资金明细,用户余额
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createOrderReward(orderNo, sourceType, money,
|
| | | new UserInfo(uid));
|
| | | userMoneyDetailService.addUserMoneyDetail(userMoneyDetail);
|
| | | userInfoService.addMoney(new UserInfo(uid), money);
|
| | | hongBaoV2Service.insertSelective(hongBaoV2);
|
| | |
|
| | | // 插入资金通知
|
| | | userMoneyMsgNotificationService.orderReward(uid, orderNo, sourceType, money,
|
| | | userInfoService.selectByPKey(uid).getMyHongBao());
|
| | | // 2.插入关联
|
| | | orderHongBaoMapService.addOrderHongBaoMap(hongBaoV2, order);
|
| | |
|
| | | /* 用户券信息状态及记录处理 */
|
| | | // 3.插入资金明细,用户余额
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createOrderReward(order.getOrderId(),
|
| | | order.getOrderType(), money, new UserInfo(uid));
|
| | | userMoneyDetailService.addUserMoneyDetail(userMoneyDetail);
|
| | | userInfoService.addMoney(new UserInfo(uid), money);
|
| | |
|
| | | Date date = new Date();
|
| | | // 更新券状态:已使用
|
| | | userSystemCoupon.setState(UserSystemCoupon.STATE_END_USE);
|
| | | userSystemCoupon.setUseTime(date);
|
| | | userSystemCoupon.setUpdateTime(date);
|
| | | userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
|
| | | // 插入资金通知
|
| | | userMoneyMsgNotificationService.orderReward(uid, order.getOrderId(), order.getOrderType(), money,
|
| | | userInfoService.selectByPKey(uid).getMyHongBao());
|
| | |
|
| | | // 插入使用券记录
|
| | | UserSystemCouponRecord couponRecord = new UserSystemCouponRecord();
|
| | | couponRecord.setState(UserSystemCouponRecord.STATE_SUCCESS);
|
| | | couponRecord.setGoodSource(sourceType);
|
| | | couponRecord.setOrderNo(orderNo);
|
| | | couponRecord.setUserSystemCoupon(userSystemCoupon);
|
| | | couponRecord.setCouponType(systemCoupon.getType().name());
|
| | | couponRecord.setCreateTime(date);
|
| | | couponRecord.setUpdateTime(date);
|
| | | userSystemCouponRecordService.insertSelective(couponRecord);
|
| | | /* 用户券信息状态及记录处理 */
|
| | |
|
| | | // 消息推送
|
| | | try {
|
| | | userOtherMsgNotificationService.rewardCouponUsed(userSystemCoupon, hongBao, money, orderNo);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | Date date = new Date();
|
| | | // 更新券状态:已使用
|
| | | userSystemCoupon.setState(UserSystemCoupon.STATE_END_USE);
|
| | | userSystemCoupon.setUseTime(date);
|
| | | userSystemCoupon.setUpdateTime(date);
|
| | | userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
|
| | |
|
| | | // 插入使用券记录
|
| | | UserSystemCouponRecord couponRecord = new UserSystemCouponRecord();
|
| | | couponRecord.setState(UserSystemCouponRecord.STATE_SUCCESS);
|
| | | couponRecord.setGoodSource(order.getOrderType());
|
| | | couponRecord.setOrderNo(order.getOrderId());
|
| | | couponRecord.setUserSystemCoupon(userSystemCoupon);
|
| | | couponRecord.setCouponType(userSystemCoupon.getSystemCoupon().getType().name());
|
| | | couponRecord.setCreateTime(date);
|
| | | couponRecord.setUpdateTime(date);
|
| | | userSystemCouponRecordService.insertSelective(couponRecord);
|
| | |
|
| | | // 消息推送
|
| | | try {
|
| | | userOtherMsgNotificationService.rewardCouponUsed(userSystemCoupon, hongBao, money, order.getOrderId());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor=Exception.class)
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void systemGiveRewardCoupon(Long uid, int num, String orderId, Integer orderType, String reason)
|
| | | throws Exception {
|
| | | // 添加奖励券
|
| | | insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(), "系统赠送",
|
| | | new BigDecimal(configService.get("exchange_rebate_percent")),false);
|
| | | new BigDecimal(configService.get("exchange_rebate_percent")), false);
|
| | | // 添加奖励券消息
|
| | | userOtherMsgNotificationService.systemGiveRewardCoupon(uid, null, MsgOtherSystemGiveDTOFactory
|
| | | .createRewardCouponGive(num, "请按照返利奖励券规则使用", "返利奖励券", orderId, orderType, reason));
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.hongbao;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.order.HongBaoV2SettleTemp;
|
| | |
|
| | | public interface HongBaoV2SettleTempService {
|
| | |
|
| | | /**
|
| | | * 添加
|
| | | * @param hongBaoList
|
| | | * @param taskKey
|
| | | * @throws Exception
|
| | | */
|
| | | public void addTemp(List<Long> hongBaoIdList, String taskKey);
|
| | | |
| | | |
| | | /**
|
| | | * 根据key检索
|
| | | * @param key
|
| | | * @return
|
| | | */
|
| | | public List<HongBaoV2SettleTemp> listByKey(String key);
|
| | | |
| | | |
| | | public long countByKey(String key);
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt;
|
| | | import com.yeshi.fanli.exception.money.InviteOrderSubsidyDebtException;
|
| | |
|
| | | public interface InviteOrderSubsidyDebtService {
|
| | |
|
| | | /**
|
| | | * 添加债务
|
| | | * |
| | | * @param debt
|
| | | * @throws InviteOrderSubsidyDebtException
|
| | | */
|
| | | public void addDebt(InviteOrderSubsidyDebt debt) throws InviteOrderSubsidyDebtException;
|
| | |
|
| | | /**
|
| | | * 偿还债务
|
| | | * |
| | | * @param debtId
|
| | | * @param money
|
| | | */
|
| | | public void repayDebt(Long debtId, BigDecimal money) throws InviteOrderSubsidyDebtException;
|
| | |
|
| | | /**
|
| | | * 还款
|
| | | * |
| | | * @param uid
|
| | | * @param money
|
| | | * @return 还剩下的资金
|
| | | * @throws InviteOrderSubsidyDebtException
|
| | | */
|
| | | public BigDecimal repayDebtByUid(Long uid, BigDecimal money) throws InviteOrderSubsidyDebtException;
|
| | |
|
| | | /**
|
| | | * 检索需要偿还的债务
|
| | | * |
| | | * @param uid
|
| | | * @param page
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | public List<InviteOrderSubsidyDebt> listNeedRepayDebt(Long uid, int page, int count);
|
| | |
|
| | | /**
|
| | | * 检索需要偿还的债务
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public long countNeedRepayDebt(Long uid);
|
| | |
|
| | | /**
|
| | | * 获取总共欠钱金额
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getTotalDebtMoney(Long uid);
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.mq;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.mq.MQUnSendInfo;
|
| | | import com.yeshi.fanli.exception.mq.MQUnSendInfoException;
|
| | |
|
| | | /**
|
| | | * 消息队列消息未发送成功服务
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public interface MQUnSendInfoService {
|
| | |
|
| | | public void addMQUnSendInfo(MQUnSendInfo info) throws MQUnSendInfoException;
|
| | |
|
| | | /**
|
| | | * 根据最大发送时间检索
|
| | | * |
| | | * @param maxSendTime
|
| | | * @param page
|
| | | * @param pageSize
|
| | | * @return
|
| | | */
|
| | | public List<MQUnSendInfo> listByMaxSendTime(Date maxSendTime, int page, int pageSize);
|
| | |
|
| | | public void deleteByPrimaryKey(Long id);
|
| | |
|
| | | /**
|
| | | * 更新发送时间
|
| | | * |
| | | * @param id
|
| | | * @param sendTime
|
| | | */
|
| | | public void updateSendTime(Long id, Date sendTime);
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import org.apache.ibatis.annotations.Param;
|
| | |
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | |
|
| | | public interface HongBaoOrderService {
|
| | |
| | | * @return
|
| | | */
|
| | | public long countByOrderNoAndHongBaoType(String orderNo, int hongBaotype, int sourceType);
|
| | | |
| | |
|
| | | /**
|
| | | * 获取详情
|
| | | * |
| | | * @param commonOrderId
|
| | | * @return
|
| | | */
|
| | | public HongBaoOrder selectDetailByCommonOrderId(Long commonOrderId);
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 获取详情
|
| | | * |
| | | * @param hongBaoId
|
| | | * @return
|
| | | */
|
| | | public HongBaoOrder selectDetailByHongBaoId(Long hongBaoId);
|
| | |
|
| | | /**
|
| | | * 根据订单号和来源类型查询
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | * @return
|
| | | */
|
| | | public List<HongBaoOrder> listByOrderIdAndSourceType(@Param("orderId") String orderId,
|
| | | @Param("sourceType") int sourceType);
|
| | |
|
| | | }
|
| | |
| | | * 订单对象
|
| | | * @param type
|
| | | * 类型
|
| | | * @return 0-未添加也未更新 1-只添加 2-只更新 12-有添加也有更新
|
| | | * @throws HongBaoException
|
| | | */
|
| | | public void addHongBao(List<CommonOrder> commonOrder, int type) throws HongBaoException;
|
| | | public int addHongBao(List<CommonOrder> commonOrder, int type) throws HongBaoException;
|
| | |
|
| | | /**
|
| | | * 奖金列表(1.4.9之前的版本)
|
| | |
| | | public List<HongBaoV2> listChildrenById(Long id);
|
| | |
|
| | | /**
|
| | | * 查询子红包
|
| | | * |
| | | * @param idList
|
| | | * @return
|
| | | */
|
| | | public List<HongBaoV2> listChildrenByIds(List<Long> idList);
|
| | |
|
| | | /**
|
| | | * 最近30天内产生过分享订单的用户
|
| | | *
|
| | | * @return
|
| | |
| | | */
|
| | | public HongBaoV2 getFirstValidHongBaoByTypeAndUid(List<Integer> typeList, Long uid);
|
| | |
|
| | | /**
|
| | | * 根据ID批量查询
|
| | | * |
| | | * @param idList
|
| | | * @return
|
| | | */
|
| | | public List<HongBaoV2> listByIds(List<Long> idList);
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | |
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
|
| | |
|
| | |
| | | public InviteOrderSubsidy getByOrderNoAndType(Long uid, String orderNo, Integer type);
|
| | |
|
| | | /**
|
| | | * 查询补贴(加锁)
|
| | | * @param uid
|
| | | * @param orderNo
|
| | | * @param type
|
| | | * @return
|
| | | */
|
| | | public InviteOrderSubsidy getByOrderNoAndTypeForUpdate(Long uid, String orderNo, Integer type);
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 添加订单补贴
|
| | | *
|
| | | * @param orderSubsidy
|
| | |
| | | */
|
| | | public void addOrderSubsidy(InviteOrderSubsidy orderSubsidy) throws InviteOrderSubsidyException;
|
| | |
|
| | | /**
|
| | | * 添加或修改(按照订单号与来源)
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | public void addOrUpdateByOrder(String orderId, int sourceType) throws InviteOrderSubsidyException;
|
| | |
|
| | | /**
|
| | | * 根据订单号与来源查询
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | * @return
|
| | | */
|
| | | public long countByOrderIdAndSourceType(String orderId, int sourceType);
|
| | |
|
| | | /**
|
| | | * 使订单号对应的数据失效
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | public void invalidByOrderIdAndSourceType(String orderId, int sourceType);
|
| | |
|
| | | |
| | | /**
|
| | | * 使订单号对应的数据有效
|
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | public void validByOrderIdAndSourceType(String orderId, int sourceType);
|
| | | |
| | | |
| | | /**
|
| | | * 结算金额
|
| | | * @param id
|
| | | * @param money
|
| | | */
|
| | | public void settleById(Long id,BigDecimal money);
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Map;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.order.OrderHongBaoMap;
|
| | |
|
| | | /**
|
| | | * 订单红包对应表用于活动)
|
| | |
| | |
|
| | | /**
|
| | | * 查找奖励金额
|
| | | * |
| | | * @param orderNo
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getCouponHongbaoByOrderNo(String orderNo, Long uid);
|
| | |
|
| | | /**
|
| | | * 根据订单ID与sourceType查询
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | * @return
|
| | | */
|
| | | public OrderHongBaoMap selectByOrderIdAndSourceType(String orderId, int sourceType);
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.order;
|
| | |
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | |
|
| | | /**
|
| | | * 订单资金结算服务
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public interface OrderMoneySettleService {
|
| | |
|
| | | /**
|
| | | * 邀请赚结算
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | public void inviteSettleTB(Long uid) throws OrderMoneySettleException;
|
| | |
|
| | | public void inviteSettleJD(Long uid) throws OrderMoneySettleException;
|
| | |
|
| | | public void inviteSettlePDD(Long uid) throws OrderMoneySettleException;
|
| | |
|
| | | /**
|
| | | * 分享赚结算
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | public void shareSettleTB(Long uid) throws OrderMoneySettleException;
|
| | |
|
| | | public void shareSettleJD(Long uid) throws OrderMoneySettleException;
|
| | |
|
| | | public void shareSettlePDD(Long uid) throws OrderMoneySettleException;
|
| | |
|
| | | /**
|
| | | * 自购结算
|
| | | * |
| | | * @param orderId
|
| | | * @param sourceType
|
| | | */
|
| | | public void ziGouSettle(String orderId, int sourceType,String taskKey) throws OrderMoneySettleException;
|
| | |
|
| | | /**
|
| | | * 邀请补贴结算
|
| | | * @param uid
|
| | | * @param taskKey
|
| | | * @throws OrderMoneySettleException
|
| | | */
|
| | | public void inviteSubsidySettle(Long uid, String taskKey) throws OrderMoneySettleException;
|
| | | }
|
| | |
| | | * @return
|
| | | */
|
| | | public BigDecimal getTLJShareRate(long time);
|
| | |
|
| | | /**
|
| | | * 获取邀请一级补贴比例
|
| | | * |
| | | * @param time
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getInviteFirstLevelSubsidyRate(Long time);
|
| | |
|
| | |
|
| | | /**
|
| | | * 获取邀请二级补贴比例
|
| | | * @param time
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getInviteSecondLevelSubsidyRate(Long time);
|
| | |
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public boolean frequencyLimit(String key, int timeS, int num) {
|
| | | key = "frequency-" + key;
|
| | | Jedis jedis = jedisPool.getResource();
|
| | | try {
|
| | | long count = jedis.incr(key);
|
| | | if (count == 1)
|
| | | jedis.expire(key, timeS);
|
| | | if (count >= num)
|
| | | return true;
|
| | | else
|
| | | return false;
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取淘宝图片
|
| | | *
|
| | |
| | | * @return
|
| | | */
|
| | | public String getSMSVCode(String phone, int type) {
|
| | | // if (!Constant.IS_OUTNET)
|
| | | // return "";
|
| | | // if (!Constant.IS_OUTNET)
|
| | | // return "";
|
| | | String key = "smscode-" + phone + "-" + type;
|
| | | // 保存2分钟
|
| | | return getString(key);
|
| | |
| | | * @param code
|
| | | */
|
| | | public void clearSMSVCode(String phone, int type) {
|
| | | // if (!Constant.IS_OUTNET)
|
| | | // return;
|
| | | // if (!Constant.IS_OUTNET)
|
| | | // return;
|
| | | String key = "smscode-" + phone + "-" + type;
|
| | | removeKey(key);
|
| | | }
|
| | |
| | | String value = getCommonString(key);
|
| | | return JsonUtil.jsonToList(value, clazz);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | public JDGoods getJDGoods(long goodsId) {
|
| | | String key = "jingdong-goods-" + goodsId;
|
| | | |
| | |
|
| | | String value = getCommonString(key);
|
| | | if (StringUtil.isNullOrEmpty(value)) {
|
| | | JDGoods jdGoods = JDApiUtil.queryGoodsDetail(goodsId);
|
| | |
| | | // 缓存20分钟
|
| | | if (jdGoods != null)
|
| | | cacheCommonString(key, JsonUtil.getSimpleGson().toJson(jdGoods), 60 * 20);
|
| | | |
| | |
|
| | | return jdGoods;
|
| | | } else {// 直接取缓存
|
| | | return JsonUtil.getSimpleGson().fromJson(value, JDGoods.class);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | public PDDGoodsDetail getPDDGoodsDetail(long goodsId) {
|
| | | String key = "pinduoduo-goods-" + goodsId;
|
| | | |
| | |
|
| | | String value = getCommonString(key);
|
| | | if (StringUtil.isNullOrEmpty(value)) {
|
| | | PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(goodsId);
|
| | |
| | | // 缓存20分钟
|
| | | if (pddGoods != null)
|
| | | cacheCommonString(key, JsonUtil.getSimpleGson().toJson(pddGoods), 60 * 20);
|
| | | |
| | |
|
| | | return pddGoods;
|
| | | } else {// 直接取缓存
|
| | | return JsonUtil.getSimpleGson().fromJson(value, PDDGoodsDetail.class);
|
| | |
| | | HongBaoV2 hongBaoV2 = hongBaoV2Service.selectByPrimaryKey(hongBaoId);
|
| | | if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU
|
| | | && hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) {
|
| | | // 到账送金币
|
| | | fanliGetIntegral(hongBaoV2);
|
| | | HongBaoRecieveCMQManager.getInstance()
|
| | | .deleteQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, key);
|
| | | |
| | | //返利不足0.01元送金币
|
| | | if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购
|
| | | // 判断是否为该用户的首笔红包
|
| | | List<Integer> typeList = new ArrayList<>();
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | HongBaoRecieveCMQManager.getInstance()
|
| | | .deleteQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, key);
|
| | |
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | });
|
| | | }
|
| | |
|
| | | private void fanliGetIntegral(HongBaoV2 hongBaoV2) {
|
| | | if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU
|
| | | && hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) {
|
| | | if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购订单
|
| | | integralGetService.addRebateOrder(hongBaoV2.getUserInfo().getId());
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 分享订单
|
| | | integralGetService.addShareOrder(hongBaoV2.getUserInfo().getId());
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级邀请
|
| | | integralGetService.addInviteOrderLevelOne(hongBaoV2.getUserInfo().getId());
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_ERJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级邀请
|
| | | integralGetService.addInviteOrderLevelTwo(hongBaoV2.getUserInfo().getId());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private boolean isFirstValidOrder(String orderId, int sourceType, Long uid) {
|
| | | CommonOrder commonOrder = commonOrderService.selectLatestValidByUid(uid);
|
| | | if (commonOrder != null && commonOrder.getOrderNo().equalsIgnoreCase(orderId)
|
| | |
| | | package com.yeshi.fanli.util.elme;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Properties;
|
| | |
|
| | | import javax.mail.Folder;
|
| | | import javax.mail.Message;
|
| | | import javax.mail.Part;
|
| | | import javax.mail.Session;
|
| | | import javax.mail.Store;
|
| | | import javax.mail.internet.MimeMessage;
|
| | |
|
| | | import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
| | | import org.apache.poi.ss.usermodel.Cell;
|
| | | import org.apache.poi.ss.usermodel.Row;
|
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
| | | import org.yeshi.utils.mail.ShowMail;
|
| | |
|
| | | import com.yeshi.fanli.entity.elme.ElmeOrder;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | import jxl.Sheet;
|
| | | import jxl.Workbook;
|
| | |
|
| | | public class ElmeOrderUtil {
|
| | |
|
| | | /**
|
| | | * 解析订单(从输入流)
|
| | | * |
| | | * @param input
|
| | | * @return
|
| | | */
|
| | | public static List<ElmeOrder> parseOrder(InputStream input) {
|
| | | public static List<ElmeOrder> parseOrder(InputStream is) {
|
| | | List<ElmeOrder> list = new ArrayList<>();
|
| | |
|
| | | org.apache.poi.ss.usermodel.Workbook wb = null;
|
| | | try {
|
| | | jxl.Workbook rwb = Workbook.getWorkbook(input);
|
| | | Sheet sheet = rwb.getSheet(0);
|
| | | for (int r = 1; r < sheet.getRows(); r++) {
|
| | | ElmeOrder order = new ElmeOrder();
|
| | | for (int c = 0; c < sheet.getColumns(); c++) {
|
| | | String content = sheet.getCell(c, r).getContents();
|
| | | String columnName = sheet.getCell(c, 0).getContents().trim();
|
| | | switch (columnName) {
|
| | | case "渠道号":
|
| | | order.setChannelId(content);
|
| | | break;
|
| | | case "渠道名称":
|
| | | order.setChannelName(content);
|
| | | break;
|
| | | case "track_pid":
|
| | | order.setTrackPid(content);
|
| | | break;
|
| | | case "rid":
|
| | | order.setRid(content);
|
| | | break;
|
| | | case "订单日期":
|
| | | order.setOrderDate(new Date(TimeUtil.convertToTimeTemp(content, "yyyy-MM-dd")));
|
| | | break;
|
| | | case "订单号":
|
| | | order.setOrderId(content.replace("<", "").replace(">", ""));
|
| | | break;
|
| | | case "支付金额":
|
| | | order.setPayMoney(new BigDecimal(content));
|
| | | break;
|
| | | case "下单城市":
|
| | | order.setCity(content);
|
| | | break;
|
| | | case "用券金额":
|
| | | order.setCouponMoney(new BigDecimal(content));
|
| | | break;
|
| | | case "是否新客首单":
|
| | | order.setNewerFirstOrder(Integer.parseInt(content));
|
| | | break;
|
| | | case "是否新客复购单":
|
| | | order.setNewerRepayOrder(Integer.parseInt(content));
|
| | | break;
|
| | | case "是否使用淘客红包":
|
| | | order.setTaokeHongBao(Integer.parseInt(content));
|
| | | break;
|
| | | case "是否有在会场内该门店的点击记录":
|
| | | order.setShopClick(Integer.parseInt(content));
|
| | | break;
|
| | | case "是否领券后7天内首单":
|
| | | order.setRecieveCoupon7DayFirstOrder(Integer.parseInt(content));
|
| | | break;
|
| | | case "是否6结佣":
|
| | | if ("是".equalsIgnoreCase(content))
|
| | | order.setIsSettle(true);
|
| | | else
|
| | | order.setIsSettle(false);
|
| | | break;
|
| | | }
|
| | | }
|
| | | list.add(order);
|
| | | }
|
| | | rwb.close();
|
| | | } catch (Exception e) {
|
| | | wb = new XSSFWorkbook(is);
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | // 开始解析
|
| | | org.apache.poi.ss.usermodel.Sheet sheet = wb.getSheetAt(0);
|
| | |
|
| | | Row firstRow = sheet.getRow(0);
|
| | | for (int r = 1; r <= sheet.getLastRowNum(); r++) {
|
| | | ElmeOrder order = new ElmeOrder();
|
| | | Row row = sheet.getRow(r);
|
| | | for (int c = row.getFirstCellNum(); c < row.getLastCellNum(); c++) {
|
| | | Cell cell = row.getCell(c);
|
| | | String content = null;
|
| | |
|
| | | String columnName = firstRow.getCell(c).getStringCellValue().trim();
|
| | | if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
|
| | | if (HSSFDateUtil.isCellDateFormatted(cell)) { // 判断日期类型
|
| | | Date date = cell.getDateCellValue();
|
| | | content = TimeUtil.getGernalTime(date.getTime(), "yyyy-MM-dd");
|
| | | } else { // 否
|
| | | content = cell.getNumericCellValue() + "";
|
| | | }
|
| | |
|
| | | } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
|
| | | content = (cell.getStringCellValue());
|
| | | }
|
| | | switch (columnName) {
|
| | | case "渠道号":
|
| | | order.setChannelId(new BigDecimal(content).longValue()+"");
|
| | | break;
|
| | | case "渠道名称":
|
| | | order.setChannelName(content);
|
| | | break;
|
| | | case "track_pid":
|
| | | order.setTrackPid(content);
|
| | | break;
|
| | | case "rid":
|
| | | order.setRid(new BigDecimal(content).longValue()+"");
|
| | | break;
|
| | | case "订单日期":
|
| | | order.setOrderDate(new Date(TimeUtil.convertToTimeTemp(content, "yyyy-MM-dd")));
|
| | | break;
|
| | | case "订单号":
|
| | | order.setOrderId(content.replace("<", "").replace(">", "").replace("<", "").replace(">", ""));
|
| | | break;
|
| | | case "支付金额":
|
| | | order.setPayMoney(new BigDecimal(content));
|
| | | break;
|
| | | case "下单城市":
|
| | | order.setCity(content);
|
| | | break;
|
| | | case "用券金额":
|
| | | order.setCouponMoney(new BigDecimal(content));
|
| | | break;
|
| | | case "是否新客首单":
|
| | | order.setNewerFirstOrder(new BigDecimal(content).intValue());
|
| | | break;
|
| | | case "是否新客复购单":
|
| | | order.setNewerRepayOrder(new BigDecimal(content).intValue());
|
| | | break;
|
| | | case "是否使用淘客红包":
|
| | | order.setTaokeHongBao(new BigDecimal(content).intValue());
|
| | | break;
|
| | | case "是否有在会场内该门店的点击记录":
|
| | | order.setShopClick(new BigDecimal(content).intValue());
|
| | | break;
|
| | | case "是否领券后7天内首单":
|
| | | order.setRecieveCoupon7DayFirstOrder(new BigDecimal(content).intValue());
|
| | | break;
|
| | | case "是否6结佣":
|
| | | if ("是".equalsIgnoreCase(content))
|
| | | order.setIsSettle(true);
|
| | | else
|
| | | order.setIsSettle(false);
|
| | | break;
|
| | | }
|
| | | }
|
| | | list.add(order);
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
| | | return MoneyBigDecimalUtil.mul(payMoney, new BigDecimal("0.06"));
|
| | | }
|
| | |
|
| | | public static List<ElmeOrder> pullLatest5DayOrder() {
|
| | | List<ElmeOrder> totalOrderList = new ArrayList<>();
|
| | | String host = "pop.qq.com";
|
| | | String username = "2780501319@qq.com";
|
| | | String password = "dbltidaeknumdgfd";
|
| | | Properties props = new Properties();
|
| | | Session session = Session.getDefaultInstance(props, null);
|
| | | try {
|
| | | Store store = session.getStore("pop3");
|
| | | store.connect(host, username, password);
|
| | | Folder folder = store.getFolder("INBOX");
|
| | | folder.open(Folder.READ_ONLY);
|
| | | Message message[] = folder.getMessages();
|
| | | List<Message> list = Arrays.asList(message);
|
| | | int count = 0;
|
| | | for (int i = list.size() - 1; i >= 0; i--) {
|
| | | ShowMail showMail = new ShowMail((MimeMessage) list.get(i));
|
| | | if ("qiuming.wu<qiuming.wu@ele.me>".equalsIgnoreCase(showMail.getFrom())) {
|
| | | if (count++ > 4)
|
| | | break;
|
| | | boolean attch = showMail.isContainAttach((Part) list.get(i));
|
| | | if (attch) {
|
| | | List<InputStream> attchList = showMail.saveAttachMent((Part) list.get(i));
|
| | | if (attchList.size() > 0) {
|
| | | List<ElmeOrder> orderList = ElmeOrderUtil.parseOrder(attchList.get(0));
|
| | | if (orderList != null && orderList.size() > 0)
|
| | | totalOrderList.addAll(orderList);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return totalOrderList;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | detail.setType(UserMoneyDetailTypeEnum.extract);
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setUserInfo(extract.getUserInfo());
|
| | | detail.setShow(false);
|
| | | return detail;
|
| | | }
|
| | |
|
| | |
| | | detail.setType(UserMoneyDetailTypeEnum.extractReject);
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setUserInfo(extract.getUserInfo());
|
| | | detail.setShow(false);// 隐藏提现失败记录
|
| | | return detail;
|
| | | }
|
| | |
|
| | |
| | | return detail;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 邀请奖金到账
|
| | | * |
| | | * @param uid
|
| | | * @param validCount
|
| | | * @param weiQuanCount
|
| | | * @param invalidCount
|
| | | * @param money
|
| | | * @param time
|
| | | * @return
|
| | | * @throws UserMoneyDetailException
|
| | | */
|
| | | public static UserMoneyDetail createInviteSubsidy(Long uid, int orderType, BigDecimal money, Date time)
|
| | | throws UserMoneyDetailException {
|
| | | if (money == null)
|
| | | throw new UserMoneyDetailException(1, "返利金额为空");
|
| | |
|
| | | if (uid == null)
|
| | | throw new UserMoneyDetailException(1, "UID为空");
|
| | |
|
| | | if (time == null)
|
| | | throw new UserMoneyDetailException(1, "发生时间为空");
|
| | |
|
| | | Calendar ca = Calendar.getInstance();
|
| | | ca.setTime(time);
|
| | | ca.add(Calendar.MONTH, -1);
|
| | |
|
| | | String timeF = TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy.M");
|
| | |
|
| | | UserMoneyDetail detail = new UserMoneyDetail();
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setIdentifyCode(
|
| | | StringUtil.Md5(UserMoneyDetailTypeEnum.subsidy.name() + "-" + orderType + "-" + uid + "-" + timeF));
|
| | | detail.setMoney(money);
|
| | | detail.setTitle(
|
| | | timeF + UserMoneyDetailTypeEnum.subsidy.getDesc() + "[" + Constant.getSourceName(orderType) + "]");
|
| | | detail.setType(UserMoneyDetailTypeEnum.subsidy);
|
| | | detail.setDescInfo("邀请订单补贴");
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setUserInfo(new UserInfo(uid));
|
| | | detail.setOrderType(orderType);
|
| | | return detail;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq;
|
| | |
|
| | | public class MQTagConstant {
|
| | | public final static String TAG_ORDER_STATISTIC_PREFIX = "orderhongbao-";// 订单统计
|
| | | public final static String TAG_ORDER_FANLI_PREFIX = "orderhongbaofanli-";// 订单到账
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq;
|
| | |
|
| | | public enum MQTopicName {
|
| | | TOPIC_ORDER("订单"), TOPIC_FANLI("返利到账"), TOPIC_SYSTEM_COUPON_USE("券使用");
|
| | | private final String desc;
|
| | |
|
| | | private MQTopicName(String desc) {
|
| | | this.desc = desc;
|
| | | }
|
| | |
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.SendResult;
|
| | | import com.aliyun.openservices.ons.api.bean.TransactionProducerBean;
|
| | | import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter;
|
| | |
|
| | | public class MyTransactionProducer extends TransactionProducerBean {
|
| | |
|
| | | public SendResult sendMsg(Message message, LocalTransactionExecuter executer, Object arg) {
|
| | | return super.send(message, executer, arg);
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq.consumer.order;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Action;
|
| | | import com.aliyun.openservices.ons.api.ConsumeContext;
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.MessageListener;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.aliyun.openservices.ons.api.SendResult;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.order.OrderMQMsgDTO;
|
| | | import com.yeshi.fanli.dto.order.OrderMoneyRecievedMQMsgDTO;
|
| | | import com.yeshi.fanli.dto.user.coupon.UserSystemCouponUseMQMsgDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
|
| | | import com.yeshi.fanli.entity.mq.MQUnSendInfo;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.mq.MQUnSendInfoException;
|
| | | import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
|
| | | import com.yeshi.fanli.service.inter.mq.MQUnSendInfoService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderMoneySettleService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | /**
|
| | | * 邀请订单补贴消息消费
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Component
|
| | | public class InviteOrderSubsidyMessageListener implements MessageListener {
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponRecordService userSystemCouponRecordService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | | @Resource
|
| | | private MQUnSendInfoService mqUnSendInfoService;
|
| | |
|
| | | @Resource
|
| | | private OrderMoneySettleService orderMoneySettleService;
|
| | |
|
| | | public InviteOrderSubsidyMessageListener() {
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Action consume(Message message, ConsumeContext context) {
|
| | |
|
| | | if (!Constant.IS_TASK) {// 非任务服务器不能消费消息
|
| | | return Action.ReconsumeLater;
|
| | | }
|
| | |
|
| | | if (MQTopicName.TOPIC_ORDER.name().equalsIgnoreCase(message.getTopic())) {
|
| | | // 查询上级红包
|
| | | OrderMQMsgDTO dto = new Gson().fromJson(new String(message.getBody()), OrderMQMsgDTO.class);
|
| | | if (dto != null) {
|
| | | try {
|
| | | inviteOrderSubsidyService.addOrUpdateByOrder(dto.getOrderId(), dto.getType());
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | return Action.ReconsumeLater;
|
| | | }
|
| | | }
|
| | | } else if (MQTopicName.TOPIC_FANLI.name().equalsIgnoreCase(message.getTopic())) {
|
| | | if (message.getTag().equalsIgnoreCase("actual")) {
|
| | | OrderMoneyRecievedMQMsgDTO dto = new Gson().fromJson(new String(message.getBody()),
|
| | | OrderMoneyRecievedMQMsgDTO.class);
|
| | | if (dto != null) {
|
| | | if (dto.getType() == OrderMoneyRecievedMQMsgDTO.TYPE_ZIGOU) {// 自购到账
|
| | | // 判断订单号是否在补贴中
|
| | | long count = inviteOrderSubsidyService.countByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | if (count > 0) {// 延时消息发送
|
| | | sendOrderSubsidyUpdateLater(dto, 5);
|
| | | }
|
| | | } else if (dto.getType() == OrderMoneyRecievedMQMsgDTO.TYPE_INVITE) {// 邀请到账
|
| | | // 补贴到账
|
| | | try {
|
| | | orderMoneySettleService.inviteSubsidySettle(dto.getUid(), message.getKey());
|
| | | return Action.CommitMessage;
|
| | | } catch (OrderMoneySettleException e) {
|
| | | return Action.ReconsumeLater;
|
| | | }
|
| | | }
|
| | | }
|
| | | } else if (message.getTag().equalsIgnoreCase("delay")) {
|
| | | OrderMoneyRecievedMQMsgDTO dto = new Gson().fromJson(new String(message.getBody()),
|
| | | OrderMoneyRecievedMQMsgDTO.class);
|
| | | if (dto != null) {
|
| | | if (dto.getType() == OrderMoneyRecievedMQMsgDTO.TYPE_ZIGOU) {// 延时时间已到
|
| | | // 判断订单号是否在补贴中
|
| | | long count = inviteOrderSubsidyService.countByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | if (count > 0) {
|
| | | // 判断是否要使用奖励券
|
| | | UserSystemCouponRecord record = userSystemCouponRecordService
|
| | | .getRecordByOrderNo(dto.getOrderId(), UserSystemCouponRecord.STATE_SUCCESS);
|
| | | if (record != null
|
| | | && record.getCouponType()
|
| | | .equalsIgnoreCase(SystemCoupon.CouponTypeEnum.rebatePercentCoupon.name())
|
| | | && record.getGoodSource() == dto.getSourceType()) {// 成功使用了奖励券
|
| | | inviteOrderSubsidyService.invalidByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | } else {
|
| | | // 使数据有效
|
| | | inviteOrderSubsidyService.validByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | } else if (MQTopicName.TOPIC_SYSTEM_COUPON_USE.name().equalsIgnoreCase(message.getTopic())) {// 奖励券使用成功
|
| | | UserSystemCouponUseMQMsgDTO dto = new Gson().fromJson(new String(message.getBody()),
|
| | | UserSystemCouponUseMQMsgDTO.class);
|
| | | if (dto != null) {
|
| | | long count = inviteOrderSubsidyService.countByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | if (count > 0) {
|
| | | // 使相关订单失效
|
| | | inviteOrderSubsidyService.invalidByOrderIdAndSourceType(dto.getOrderId(), dto.getSourceType());
|
| | | }
|
| | | return Action.CommitMessage;
|
| | | }
|
| | | }
|
| | | return Action.CommitMessage;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 发送订单延时消息
|
| | | * |
| | | * @param day
|
| | | */
|
| | | private boolean sendOrderSubsidyUpdateLater(OrderMoneyRecievedMQMsgDTO dto, int day) {
|
| | |
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "delay", new Gson().toJson(dto).getBytes());
|
| | | msg.setKey(dto.getSourceType() + "_" + dto.getOrderId());
|
| | | long delayTime = System.currentTimeMillis() + 1000 * 60 * 60 * 24L * day;
|
| | | msg.setStartDeliverTime(delayTime);
|
| | | SendResult sendResult = producer.send(msg);
|
| | | if (sendResult != null) {
|
| | | return true;
|
| | | } else {
|
| | | MQUnSendInfo info = new MQUnSendInfo();
|
| | | info.setBody(new String(msg.getBody()));
|
| | | if (msg.getStartDeliverTime() > 0)
|
| | | info.setDeliverTime(new Date(msg.getStartDeliverTime()));
|
| | | info.setKey(msg.getKey());
|
| | | info.setTag(msg.getTag());
|
| | | info.setTopic(msg.getTopic());
|
| | | try {
|
| | | mqUnSendInfoService.addMQUnSendInfo(info);
|
| | | } catch (MQUnSendInfoException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq.order;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.transaction.LocalTransactionChecker;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.order.OrderMoneyRecievedMQMsgDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2SettleTempService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTagConstant;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | @Component
|
| | | public class MQLocalTransactionChecker implements LocalTransactionChecker {
|
| | |
|
| | | @Resource
|
| | | private MQLocalUserCouponUsedTransactionChecker mqLocalUserCouponUsedTransactionChecker;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2SettleTempService hongBaoV2SettleTempService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | |
|
| | | public MQLocalTransactionChecker() {
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TransactionStatus check(Message msg) {
|
| | |
|
| | | if (msg.getTopic().equalsIgnoreCase(MQTopicName.TOPIC_ORDER.name())) {
|
| | | if (msg.getTag().startsWith(MQTagConstant.TAG_ORDER_STATISTIC_PREFIX)) {// 订单加入红包标识
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | } else if (msg.getTopic().equalsIgnoreCase(MQTopicName.TOPIC_FANLI.name())) {
|
| | | if (msg.getTag().equalsIgnoreCase("actual")) {// 查询key值是否在
|
| | | if (hongBaoV2SettleTempService.countByKey(msg.getKey()) > 0)
|
| | | return TransactionStatus.CommitTransaction;
|
| | | else
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | } else if (msg.getTag().equalsIgnoreCase("delay")) {
|
| | | OrderMoneyRecievedMQMsgDTO dto = new Gson().fromJson(new String(msg.getBody()),
|
| | | OrderMoneyRecievedMQMsgDTO.class);
|
| | | if (dto != null) {
|
| | | if (dto.getType() == OrderMoneyRecievedMQMsgDTO.TYPE_ZIGOU) {
|
| | | // TODO 尚未处理一个订单部分到账的状况
|
| | | // 返利是否到账
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(dto.getSourceType(),
|
| | | dto.getOrderId());
|
| | | for (CommonOrder order : orderList) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderService.selectDetailByCommonOrderId(order.getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null
|
| | | && hongBaoOrder.getHongBaoV2().getState() == HongBaoV2.STATE_YILINGQU) {
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | }
|
| | |
|
| | | // 其他未知条件暂时处理为回滚
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | } else if (msg.getTopic().equalsIgnoreCase(MQTopicName.TOPIC_SYSTEM_COUPON_USE.name())) {
|
| | | return mqLocalUserCouponUsedTransactionChecker.check(msg);
|
| | | }
|
| | |
|
| | | return TransactionStatus.Unknow;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq.order;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.user.coupon.UserSystemCouponUseMQMsgDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | /**
|
| | | * 券使用事务检查
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Component
|
| | | public class MQLocalUserCouponUsedTransactionChecker {
|
| | | @Resource
|
| | | private UserSystemCouponRecordService userSystemCouponRecordService;
|
| | |
|
| | | public MQLocalUserCouponUsedTransactionChecker() {
|
| | |
|
| | | }
|
| | |
|
| | | public TransactionStatus check(Message msg) {
|
| | | if (msg.getTopic().equalsIgnoreCase(MQTopicName.TOPIC_SYSTEM_COUPON_USE.name())) {
|
| | | if (msg.getTag().equalsIgnoreCase(SystemCoupon.CouponTypeEnum.rebatePercentCoupon.name())) {// 返利奖励券
|
| | | // 查询是否使用成功
|
| | | UserSystemCouponUseMQMsgDTO dto = new Gson().fromJson(new String(msg.getBody()),
|
| | | UserSystemCouponUseMQMsgDTO.class);
|
| | | UserSystemCouponRecord record = userSystemCouponRecordService
|
| | | .getNearByUserCouponId(dto.getUserSystemCouponId());
|
| | | if (record != null) {
|
| | | if (record.getOrderNo().equalsIgnoreCase(dto.getOrderId())
|
| | | && dto.getSourceType().intValue() == record.getGoodSource()) {
|
| | | return TransactionStatus.CommitTransaction;
|
| | | }
|
| | | }
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | }
|
| | | return TransactionStatus.Unknow;
|
| | | }
|
| | | }
|
| | |
| | | ScriptEngineManager manager = new ScriptEngineManager();
|
| | | ScriptEngine engine = manager.getEngineByName("javascript");
|
| | | try {
|
| | | String js = "function getData(){return JSON.stringify(dataDef);}" + content;
|
| | | String js = "function getData(){return JSON.stringify(dataDef);} var test1='--';function test2(res){};" + content.replace("$(window).load", "test2").replace("window.location.search.", "test1.");
|
| | | engine.eval(js);
|
| | | if (engine instanceof Invocable) {
|
| | | Invocable in = (Invocable) engine;
|
| | |
| | | log4j.appender.jobLog.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%c]-[%p] %m%n
|
| | |
|
| | |
|
| | | log4j.logger.mqLog=ALL,mqLog
|
| | | log4j.appender.mqLog=org.apache.log4j.DailyRollingFileAppender
|
| | | log4j.appender.mqLog.File=logs/mq/mqLog.log
|
| | | log4j.appender.mqLog.MaxFileSize=20MB
|
| | | log4j.appender.mqLog.MaxBackupIndex=100
|
| | | log4j.appender.mqLog.layout=org.apache.log4j.PatternLayout
|
| | | log4j.appender.mqLog.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%c]-[%p] %m%n
|
| | |
|
| | |
|
| | |
|
| | | log4j.appender.mongodb=org.apache.log4j.ConsoleAppender
|
| | | log4j.appender.mongodb.Target=System.out
|
| | | log4j.appender.mongodb.Threshold=DEBUG
|
| | |
| | | <beans xmlns="http://www.springframework.org/schema/beans"
|
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| | | xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
| | | <bean id="msgListener" class="com.yeshi.fanli.util.rocketmq.RocketMQMessageListener"></bean> <!--Listener 配置 -->
|
| | | <bean id="inviteOrderSubsidyMsgListener" class="com.yeshi.fanli.util.rocketmq.consumer.order.InviteOrderSubsidyMessageListener"></bean> <!--Listener 配置 -->
|
| | | <!-- Group ID 订阅同一个 Topic,可以创建多个 ConsumerBean -->
|
| | | <bean id="consumer" class="com.aliyun.openservices.ons.api.bean.ConsumerBean"
|
| | | <bean id="orderTransactionConsumer" class="com.aliyun.openservices.ons.api.bean.ConsumerBean"
|
| | | init-method="start" destroy-method="shutdown">
|
| | | <property name="properties"> <!--消费者配置信息 -->
|
| | | <props>
|
| | | <prop key="AccessKey">LTAI4FwmTxVCuzTaoZtDiV8z</prop>
|
| | | <prop key="SecretKey">ixWg90QbYFKP6ae5xpAo2P1qwIyll5</prop>
|
| | | <prop key="GROUP_ID">GID_DEMO</prop>
|
| | | <prop key="GROUP_ID">GID_ORDER</prop>
|
| | | <prop key="NAMESRV_ADDR">http://MQ_INST_1205444665315884_BbaMbxF4.mq-internet-access.mq-internet.aliyuncs.com:80
|
| | | </prop>
|
| | | <!--将消费者线程数固定为 50 个 <prop key="ConsumeThreadNums">50</prop> -->
|
| | |
| | | </property>
|
| | | <property name="subscriptionTable">
|
| | | <map>
|
| | | <entry value-ref="msgListener">
|
| | | <!-- 订单补贴订阅 -->
|
| | | <entry value-ref="inviteOrderSubsidyMsgListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TopicTestMQ" />
|
| | | <property name="topic" value="TOPIC_ORDER" />
|
| | | <property name="expression" value="*" /><!--expression 即
|
| | | Tag,可以设置成具体的 Tag,如 taga||tagb||tagc,也可设置成 *。 * 仅代表订阅所有 Tag,不支持通配 -->
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | | <!--更多的订阅添加 entry 节点即可,如下所示 -->
|
| | | <entry value-ref="msgListener">
|
| | | |
| | | <entry value-ref="inviteOrderSubsidyMsgListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TopicTestMQ-Other" /> <!--订阅另外一个 Topic -->
|
| | | <property name="expression" value="taga||tagb" /> <!-- 订阅多个 Tag -->
|
| | | <property name="topic" value="TOPIC_FANLI" />
|
| | | <property name="expression" value="*" /><!--expression 即 |
| | | Tag,可以设置成具体的 Tag,如 taga||tagb||tagc,也可设置成 *。 * 仅代表订阅所有 Tag,不支持通配 -->
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | | |
| | | |
| | | <entry value-ref="inviteOrderSubsidyMsgListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_SYSTEM_COUPON_USE" />
|
| | | <property name="expression" value="rebatePercentCoupon" />
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | | |
| | | </map>
|
| | | </property>
|
| | | </bean>
|
| | |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| | | xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
| | | <!-- 事务消息生产 -->
|
| | | <bean id="localTransactionChecker" class="com.yeshi.fanli.util.rocketmq.RocketMQLocalTransactionChecker"></bean>
|
| | | <bean id="transactionProducer"
|
| | | <bean id="localTransactionChecker" class="com.yeshi.fanli.util.rocketmq.order.MQLocalTransactionChecker"></bean>
|
| | | <bean id="orderTransactionProducer"
|
| | | class="com.aliyun.openservices.ons.api.bean.TransactionProducerBean"
|
| | | init-method="start" destroy-method="shutdown">
|
| | | <property name="properties"> <!--事务消息生产者配置信息 -->
|
| | | <props>
|
| | | <prop key="AccessKey">LTAI4FwmTxVCuzTaoZtDiV8z</prop>
|
| | | <prop key="SecretKey">ixWg90QbYFKP6ae5xpAo2P1qwIyll5</prop>
|
| | | <prop key="GROUP_ID">GID_DEMO</prop>
|
| | | <prop key="GROUP_ID">GID_ORDER</prop>
|
| | | <prop key="NAMESRV_ADDR">http://MQ_INST_1205444665315884_BbaMbxF4.mq-internet-access.mq-internet.aliyuncs.com:80
|
| | | </prop>
|
| | | </props>
|
| | | </property>
|
| | | <property name="localTransactionChecker" ref="localTransactionChecker"></property>
|
| | | </bean>
|
| | | |
| | | |
| | | |
| | | </beans> |
| | |
| | | <artifactId>thumbnailator</artifactId>
|
| | | <version>0.4.8</version>
|
| | | </dependency>
|
| | |
|
| | | |
| | | <!-- RocketMQ -->
|
| | | <dependency>
|
| | | <groupId>com.aliyun.openservices</groupId>
|
| | | <artifactId>ons-client</artifactId>
|
| | | <version>1.8.0.Final</version>
|
| | | </dependency>
|
| | |
|
| | | <!-- 分步式任务 -->
|
| | | <dependency>
|
| | | <groupId>com.xuxueli</groupId>
|
| | | <artifactId>xxl-job-core</artifactId>
|
| | | <version>2.1.0</version>
|
| | | </dependency>
|
| | |
|
| | | </dependencies>
|
| | |
|
New file |
| | |
| | | package org.yeshi.utils.mail;
|
| | |
|
| | | import java.io.BufferedInputStream;
|
| | | import java.io.BufferedOutputStream;
|
| | | import java.io.File;
|
| | | import java.io.FileOutputStream;
|
| | | import java.io.InputStream;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.mail.BodyPart;
|
| | | import javax.mail.Flags;
|
| | | import javax.mail.Message;
|
| | | import javax.mail.MessagingException;
|
| | | import javax.mail.Multipart;
|
| | | import javax.mail.Part;
|
| | | import javax.mail.internet.InternetAddress;
|
| | | import javax.mail.internet.MimeMessage;
|
| | | import javax.mail.internet.MimeUtility;
|
| | |
|
| | | public class ShowMail {
|
| | |
|
| | | private MimeMessage mimeMessage = null;
|
| | |
|
| | | private String saveAttachPath = ""; // 附件下载后的存放目录
|
| | |
|
| | | private StringBuffer bodyText = new StringBuffer(); // 存放邮件内容的StringBuffer对象
|
| | |
|
| | | private String dateFormat = "yy-MM-dd HH:mm"; // 默认的日前显示格式
|
| | |
|
| | | /**
|
| | | * |
| | | * 构造函数,初始化一个MimeMessage对象
|
| | | * |
| | | */
|
| | |
|
| | | public ShowMail() {
|
| | |
|
| | | }
|
| | |
|
| | | public ShowMail(MimeMessage mimeMessage) {
|
| | |
|
| | | this.mimeMessage = mimeMessage;
|
| | |
|
| | | // System.out.println("创建一个ReceiveEmail对象....");
|
| | |
|
| | | }
|
| | |
|
| | | public void setMimeMessage(MimeMessage mimeMessage) {
|
| | |
|
| | | this.mimeMessage = mimeMessage;
|
| | |
|
| | | // System.out.println("设置一个MimeMessage对象...");
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * * 获得发件人的地址和姓名
|
| | | * |
| | | */
|
| | |
|
| | | public String getFrom() throws Exception {
|
| | |
|
| | | InternetAddress address[] = (InternetAddress[]) mimeMessage.getFrom();
|
| | |
|
| | | String from = address[0].getAddress();
|
| | |
|
| | | if (from == null) {
|
| | |
|
| | | from = "";
|
| | |
|
| | | // System.out.println("无法知道发送者.");
|
| | |
|
| | | }
|
| | |
|
| | | String personal = address[0].getPersonal();
|
| | |
|
| | | if (personal == null) {
|
| | |
|
| | | personal = "";
|
| | |
|
| | | // System.out.println("无法知道发送者的姓名.");
|
| | |
|
| | | }
|
| | |
|
| | | String fromAddr = null;
|
| | |
|
| | | if (personal != null || from != null) {
|
| | | fromAddr = personal + "<" + from + ">";
|
| | | // System.out.println("发送者是:" + fromAddr);
|
| | | }
|
| | | return fromAddr;
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * * 获得邮件的收件人,抄送,和密送的地址和姓名,根据所传递的参数的不同
|
| | | * |
| | | * * "to"----收件人 "cc"---抄送人地址 "bcc"---密送人地址
|
| | | * |
| | | */
|
| | |
|
| | | public String getMailAddress(String type) throws Exception {
|
| | |
|
| | | String mailAddr = "";
|
| | |
|
| | | String addType = type.toUpperCase();
|
| | |
|
| | | InternetAddress[] address = null;
|
| | |
|
| | | if (addType.equals("TO") || addType.equals("CC")
|
| | |
|
| | | || addType.equals("BCC")) {
|
| | |
|
| | | if (addType.equals("TO")) {
|
| | |
|
| | | address = (InternetAddress[]) mimeMessage
|
| | |
|
| | | .getRecipients(Message.RecipientType.TO);
|
| | |
|
| | | } else if (addType.equals("CC")) {
|
| | |
|
| | | address = (InternetAddress[]) mimeMessage
|
| | |
|
| | | .getRecipients(Message.RecipientType.CC);
|
| | |
|
| | | } else {
|
| | |
|
| | | address = (InternetAddress[]) mimeMessage
|
| | |
|
| | | .getRecipients(Message.RecipientType.BCC);
|
| | |
|
| | | }
|
| | |
|
| | | if (address != null) {
|
| | |
|
| | | for (int i = 0; i < address.length; i++) {
|
| | |
|
| | | String emailAddr = address[i].getAddress();
|
| | |
|
| | | if (emailAddr == null) {
|
| | |
|
| | | emailAddr = "";
|
| | |
|
| | | } else {
|
| | |
|
| | | // System.out.println("转换之前的emailAddr: " + emailAddr);
|
| | |
|
| | | emailAddr = MimeUtility.decodeText(emailAddr);
|
| | |
|
| | | // System.out.println("转换之后的emailAddr: " + emailAddr);
|
| | |
|
| | | }
|
| | |
|
| | | String personal = address[i].getPersonal();
|
| | |
|
| | | if (personal == null) {
|
| | |
|
| | | personal = "";
|
| | |
|
| | | } else {
|
| | |
|
| | | // System.out.println("转换之前的personal: " + personal);
|
| | |
|
| | | personal = MimeUtility.decodeText(personal);
|
| | |
|
| | | // System.out.println("转换之后的personal: " + personal);
|
| | |
|
| | | }
|
| | |
|
| | | String compositeto = personal + "<" + emailAddr + ">";
|
| | |
|
| | | // System.out.println("完整的邮件地址:" + compositeto);
|
| | |
|
| | | mailAddr += "," + compositeto;
|
| | |
|
| | | }
|
| | |
|
| | | mailAddr = mailAddr.substring(1);
|
| | |
|
| | | }
|
| | |
|
| | | } else {
|
| | |
|
| | | throw new Exception("错误的电子邮件类型!");
|
| | |
|
| | | }
|
| | |
|
| | | return mailAddr;
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * * 获得邮件主题
|
| | | * |
| | | */
|
| | |
|
| | | public String getSubject() throws MessagingException {
|
| | |
|
| | | String subject = "";
|
| | |
|
| | | try {
|
| | |
|
| | | // System.out.println("转换前的subject:" + mimeMessage.getSubject());
|
| | |
|
| | | subject = MimeUtility.decodeText(mimeMessage.getSubject());
|
| | |
|
| | | // System.out.println("转换后的subject: " + mimeMessage.getSubject());
|
| | |
|
| | | if (subject == null) {
|
| | |
|
| | | subject = "";
|
| | |
|
| | | }
|
| | |
|
| | | } catch (Exception exce) {
|
| | |
|
| | | exce.printStackTrace();
|
| | |
|
| | | }
|
| | |
|
| | | return subject;
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * * 获得邮件发送日期
|
| | | * |
| | | */
|
| | |
|
| | | public String getSentDate() throws Exception {
|
| | |
|
| | | Date sentDate = mimeMessage.getSentDate();
|
| | |
|
| | | // System.out.println("发送日期 原始类型: " + dateFormat);
|
| | |
|
| | | SimpleDateFormat format = new SimpleDateFormat(dateFormat);
|
| | |
|
| | | String strSentDate = format.format(sentDate);
|
| | |
|
| | | // System.out.println("发送日期 可读类型: " + strSentDate);
|
| | |
|
| | | return strSentDate;
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * * 获得邮件正文内容
|
| | | * |
| | | */
|
| | |
|
| | | public String getBodyText() {
|
| | |
|
| | | return bodyText.toString();
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * * 解析邮件,把得到的邮件内容保存到一个StringBuffer对象中,解析邮件
|
| | | * |
| | | * * 主要是根据MimeType类型的不同执行不同的操作,一步一步的解析
|
| | | * |
| | | */
|
| | |
|
| | | public void getMailContent(Part part) throws Exception {
|
| | |
|
| | | String contentType = part.getContentType();
|
| | |
|
| | | // 获得邮件的MimeType类型
|
| | |
|
| | | // System.out.println("邮件的MimeType类型: " + contentType);
|
| | |
|
| | | int nameIndex = contentType.indexOf("name");
|
| | |
|
| | | boolean conName = false;
|
| | |
|
| | | if (nameIndex != -1) {
|
| | |
|
| | | conName = true;
|
| | |
|
| | | }
|
| | |
|
| | | // System.out.println("邮件内容的类型: " + contentType);
|
| | |
|
| | | if (part.isMimeType("text/plain") && conName == false) {
|
| | |
|
| | | // text/plain 类型
|
| | |
|
| | | bodyText.append((String) part.getContent());
|
| | |
|
| | | } else if (part.isMimeType("text/html") && conName == false) {
|
| | |
|
| | | // text/html 类型
|
| | |
|
| | | bodyText.append((String) part.getContent());
|
| | |
|
| | | } else if (part.isMimeType("multipart/*")) {
|
| | |
|
| | | // multipart/*
|
| | |
|
| | | Multipart multipart = (Multipart) part.getContent();
|
| | |
|
| | | int counts = multipart.getCount();
|
| | |
|
| | | for (int i = 0; i < counts; i++) {
|
| | |
|
| | | getMailContent(multipart.getBodyPart(i));
|
| | |
|
| | | }
|
| | |
|
| | | } else if (part.isMimeType("message/rfc822")) {
|
| | |
|
| | | // message/rfc822
|
| | |
|
| | | getMailContent((Part) part.getContent());
|
| | |
|
| | | } else {
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * * 判断此邮件是否需要回执,如果需要回执返回"true",否则返回"false"
|
| | | * |
| | | */
|
| | |
|
| | | public boolean getReplySign() throws MessagingException {
|
| | |
|
| | | boolean replySign = false;
|
| | |
|
| | | String needReply[] = mimeMessage
|
| | |
|
| | | .getHeader("Disposition-Notification-To");
|
| | |
|
| | | if (needReply != null) {
|
| | |
|
| | | replySign = true;
|
| | |
|
| | | }
|
| | |
|
| | | if (replySign) {
|
| | |
|
| | | // System.out.println("该邮件需要回复");
|
| | |
|
| | | } else {
|
| | |
|
| | | // System.out.println("该邮件不需要回复");
|
| | |
|
| | | }
|
| | |
|
| | | return replySign;
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * 获得此邮件的Message-ID
|
| | | * |
| | | */
|
| | |
|
| | | public String getMessageId() throws MessagingException {
|
| | |
|
| | | String messageID = mimeMessage.getMessageID();
|
| | |
|
| | | // System.out.println("邮件ID: " + messageID);
|
| | |
|
| | | return messageID;
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * 判断此邮件是否已读,如果未读返回false,反之返回true
|
| | | * |
| | | */
|
| | |
|
| | | public boolean isNew() throws MessagingException {
|
| | |
|
| | | boolean isNew = false;
|
| | |
|
| | | Flags flags = ((Message) mimeMessage).getFlags();
|
| | |
|
| | | Flags.Flag[] flag = flags.getSystemFlags();
|
| | |
|
| | | // System.out.println("flags的长度: " + flag.length);
|
| | |
|
| | | for (int i = 0; i < flag.length; i++) {
|
| | |
|
| | | if (flag[i] == Flags.Flag.SEEN) {
|
| | |
|
| | | isNew = true;
|
| | |
|
| | | // System.out.println("seen email...");
|
| | |
|
| | | // break;
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | return isNew;
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * 判断此邮件是否包含附件
|
| | | * |
| | | */
|
| | |
|
| | | public boolean isContainAttach(Part part) throws Exception {
|
| | |
|
| | | boolean attachFlag = false;
|
| | |
|
| | | // String contentType = part.getContentType();
|
| | |
|
| | | if (part.isMimeType("multipart/*")) {
|
| | |
|
| | | Multipart mp = (Multipart) part.getContent();
|
| | |
|
| | | for (int i = 0; i < mp.getCount(); i++) {
|
| | |
|
| | | BodyPart mPart = mp.getBodyPart(i);
|
| | |
|
| | | String disposition = mPart.getDisposition();
|
| | |
|
| | | if ((disposition != null)
|
| | |
|
| | | && ((disposition.equals(Part.ATTACHMENT)) || (disposition
|
| | |
|
| | | .equals(Part.INLINE))))
|
| | |
|
| | | attachFlag = true;
|
| | |
|
| | | else if (mPart.isMimeType("multipart/*")) {
|
| | |
|
| | | attachFlag = isContainAttach((Part) mPart);
|
| | |
|
| | | } else {
|
| | |
|
| | | String conType = mPart.getContentType();
|
| | |
|
| | | if (conType.toLowerCase().indexOf("application") != -1)
|
| | |
|
| | | attachFlag = true;
|
| | |
|
| | | if (conType.toLowerCase().indexOf("name") != -1)
|
| | |
|
| | | attachFlag = true;
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | } else if (part.isMimeType("message/rfc822")) {
|
| | |
|
| | | attachFlag = isContainAttach((Part) part.getContent());
|
| | |
|
| | | }
|
| | |
|
| | | return attachFlag;
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * * 保存附件
|
| | | * |
| | | */
|
| | |
|
| | | public List<InputStream> saveAttachMent(Part part) throws Exception {
|
| | |
|
| | | List<InputStream> inputStreamList = new ArrayList<>();
|
| | | String fileName = "";
|
| | |
|
| | | if (part.isMimeType("multipart/*")) {
|
| | |
|
| | | Multipart mp = (Multipart) part.getContent();
|
| | |
|
| | | for (int i = 0; i < mp.getCount(); i++) {
|
| | |
|
| | | BodyPart mPart = mp.getBodyPart(i);
|
| | |
|
| | | String disposition = mPart.getDisposition();
|
| | |
|
| | | if ((disposition != null)
|
| | |
|
| | | && ((disposition.equals(Part.ATTACHMENT)) || (disposition
|
| | |
|
| | | .equals(Part.INLINE)))) {
|
| | |
|
| | | fileName = mPart.getFileName();
|
| | |
|
| | | if (fileName.toLowerCase().indexOf("gb2312") != -1) {
|
| | | fileName = MimeUtility.decodeText(fileName);
|
| | | }
|
| | | inputStreamList.add(mPart.getInputStream());
|
| | | } else if (mPart.isMimeType("multipart/*")) {
|
| | | saveAttachMent(mPart);
|
| | |
|
| | | } else {
|
| | |
|
| | | fileName = mPart.getFileName();
|
| | |
|
| | | if ((fileName != null)
|
| | |
|
| | | && (fileName.toLowerCase().indexOf("GB2312") != -1)) {
|
| | |
|
| | | fileName = MimeUtility.decodeText(fileName);
|
| | | inputStreamList.add(mPart.getInputStream());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | } else if (part.isMimeType("message/rfc822")) {
|
| | | saveAttachMent((Part) part.getContent());
|
| | | }
|
| | | return inputStreamList;
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * 设置附件存放路径
|
| | | * |
| | | */
|
| | |
|
| | | public void setAttachPath(String attachPath) {
|
| | |
|
| | | this.saveAttachPath = attachPath;
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * * 设置日期显示格式
|
| | | * |
| | | */
|
| | |
|
| | | public void setDateFormat(String format) throws Exception {
|
| | |
|
| | | this.dateFormat = format;
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * * 获得附件存放路径
|
| | | * |
| | | */
|
| | |
|
| | | public String getAttachPath() {
|
| | |
|
| | | return saveAttachPath;
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * * 真正的保存附件到指定目录里
|
| | | * |
| | | */
|
| | |
|
| | | private void saveFile(String fileName, InputStream in) throws Exception {
|
| | |
|
| | | String osName = System.getProperty("os.name");
|
| | |
|
| | | String storeDir = getAttachPath();
|
| | |
|
| | | String separator = "";
|
| | |
|
| | | if (osName == null) {
|
| | |
|
| | | osName = "";
|
| | |
|
| | | }
|
| | |
|
| | | if (osName.toLowerCase().indexOf("win") != -1) {
|
| | |
|
| | | separator = "\\";
|
| | |
|
| | | if (storeDir == null || storeDir.equals(""))
|
| | |
|
| | | storeDir = "c:\\tmp";
|
| | |
|
| | | } else {
|
| | |
|
| | | separator = "/";
|
| | |
|
| | | storeDir = "/tmp";
|
| | |
|
| | | }
|
| | |
|
| | | File storeFile = new File(storeDir + separator + fileName);
|
| | |
|
| | | // System.out.println("附件的保存地址: " + storeFile.toString());
|
| | |
|
| | | // for(int i=0;storefile.exists();i++){
|
| | |
|
| | | // storefile = new File(storedir+separator+fileName+i);
|
| | |
|
| | | // }
|
| | |
|
| | | BufferedOutputStream bos = null;
|
| | |
|
| | | BufferedInputStream bis = null;
|
| | |
|
| | | try {
|
| | |
|
| | | bos = new BufferedOutputStream(new FileOutputStream(storeFile));
|
| | |
|
| | | bis = new BufferedInputStream(in);
|
| | |
|
| | | int c;
|
| | |
|
| | | while ((c = bis.read()) != -1) {
|
| | |
|
| | | bos.write(c);
|
| | |
|
| | | bos.flush();
|
| | |
|
| | | }
|
| | |
|
| | | } catch (Exception exception) {
|
| | |
|
| | | exception.printStackTrace();
|
| | |
|
| | | throw new Exception("文件保存失败!");
|
| | |
|
| | | } finally {
|
| | |
|
| | | bos.close();
|
| | |
|
| | | bis.close();
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|