Merge branch 'dev-hongbao'
Conflicts:
fanli/src/main/java/com/yeshi/fanli/util/RedisManager.java
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java
| | |
| | |
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.admin.InviteGetMoney;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
|
| | | import com.yeshi.fanli.entity.system.System;
|
| | | import com.yeshi.fanli.entity.system.SystemClientParams;
|
| | | import com.yeshi.fanli.exception.NotExistObjectException;
|
| | | import com.yeshi.fanli.exception.banner.SwiperPictureException;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.InviteGetMoneyService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.service.inter.user.QrCodeService;
|
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.service.inter.user.UserRankingsService;
|
| | |
| | | @Resource
|
| | | private UserRankingsService userRankingsService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private SwiperPictureService swiperPictureService;
|
| | |
|
| | | @RequestMapping(value = "/inviteGetMoney", method = RequestMethod.POST)
|
| | | public void everyDayTaskList(AcceptData acceptData, int pageIndex, PrintWriter out, String uid)
|
| | | throws NotExistObjectException {
|
| | |
| | |
|
| | | List<InviteGetMoney> inviteGetMoneyList = userRankingsService.getRank(0, 5);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | com.alibaba.fastjson.JSONObject data = new com.alibaba.fastjson.JSONObject();
|
| | | data.put("pageEntity", JsonUtil.getSimpleGsonWithDate().toJson(pageEntity));
|
| | | data.put("everyDayTaskList", new JSONArray());
|
| | | data.put("inviteGetMoneyList", JsonUtil.getSimpleGsonWithDate().toJson(inviteGetMoneyList));
|
| | | data.put("inviteGetMoneyList",
|
| | | JSONArray.fromObject(JsonUtil.getSimpleGsonWithDate().toJson(inviteGetMoneyList)));
|
| | | if (uid.equals("0") || uid == null) {
|
| | | data.put("myTeam", "---");
|
| | | data.put("moneyToday", "---");
|
| | |
| | | data.put("activityRules", valueBr);
|
| | | data.put("inviteList", String.format("http://%s/%s/client/share/friends_new.html",
|
| | | Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName()));
|
| | | out.print(JsonUtil.loadTrue(0, JsonUtil.getSimpleGson().toJson(data), "成功"));
|
| | | try {
|
| | | List<SwiperPicture> pictureList = swiperPictureService.getByBannerCard("invite_top_banner");
|
| | | if (pictureList != null && pictureList.size() > 0) {
|
| | | SwiperPicture picture = pictureList.get(0);
|
| | | com.alibaba.fastjson.JSONObject pictureJson = new com.alibaba.fastjson.JSONObject();
|
| | | pictureJson.put("src", picture.getSrc());
|
| | | pictureJson.put("jumpDetail", picture.getJumpDetail());
|
| | | pictureJson.put("params", picture.getParams());
|
| | | data.put("topBanner", pictureJson);
|
| | | }
|
| | |
|
| | | } catch (SwiperPictureException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | com.alibaba.fastjson.JSONObject root = new com.alibaba.fastjson.JSONObject();
|
| | | root.put("code", 0);
|
| | | root.put("data", data);
|
| | |
|
| | | out.print(JsonUtil.loadTrue(0, root, "成功"));
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | BigDecimal balance = userInfoService.getMyHB(uid);
|
| | | BigDecimal balance = userInfoService.getUserById(uid).getMyHongBao();
|
| | |
|
| | | UserMoneyStatisticVO vo = new UserMoneyStatisticVO();
|
| | | vo.setBalanceMoney(balance);
|
| | |
| | | package com.yeshi.fanli.dao.mybatis; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2; |
| | | |
| | | public interface HongBaoV2Mapper extends BaseMapper<HongBaoV2> { |
| | | |
| | | /** |
| | | * 获取子红包列表 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | List<HongBaoV2> listChildrenById(Long id); |
| | | |
| | | } |
| | |
| | | */ |
| | | Map<String, BigDecimal> countByUidAndOrderState(@Param("uid") Long uid, @Param("type") Integer type, |
| | | |
| | | @Param("startTime") String startTime, @Param("endTime") String endTime,@Param("day") Integer day); |
| | | @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("day") Integer day); |
| | | |
| | | /** |
| | | * 奖金订单数量 |
| | |
| | | * @return |
| | | */ |
| | | BigDecimal countBonusOrderMoney(@Param("uid") Long uid, @Param("type") Integer type, @Param("day") Integer day); |
| | | |
| | | |
| | | |
| | | int countByOrderNOAndOrderType(@Param("orderNO") String orderNO, @Param("orderType") int orderType); |
| | | |
| | | /** |
| | | * 根据订单号与订单排序值获取详情 |
| | | * |
| | | * @param orderNo |
| | | * -订单号 |
| | | * @param orderBy |
| | | * -订单排序值 |
| | | * @param orderType |
| | | * -订单类型 |
| | | * @return |
| | | */ |
| | | CommonOrder selectByOrderNoAndOrderTypeAndOrderBy(@Param("orderNo") String orderNo, |
| | | @Param("orderType") int orderType, @Param("orderBy") int orderBy); |
| | | |
| | | } |
| | |
| | | package com.yeshi.fanli.dao.mybatis.order; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.order.HongBaoOrder; |
| | | |
| | | public interface HongBaoOrderMapper extends BaseMapper<HongBaoOrder> { |
| | | |
| | | |
| | | /** |
| | | * 根据订单ID查询对象 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | HongBaoOrder selectByCommonOrderId(Long id); |
| | | |
| | | |
| | | /** |
| | | * 返利订单列表(1.4.9之前) |
| | | * |
| | | * @param uid |
| | | * @param start |
| | | * @param count |
| | | * @return |
| | | */ |
| | | List<HongBaoOrder> listFanLiOrder(@Param("uid") Long uid, @Param("start") long start, @Param("count") int count); |
| | | |
| | | /** |
| | | * 返利订单数量(1.4.9之前) |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | Long countFanLiOrder(Long uid); |
| | | |
| | | } |
| | |
| | | // 按订单号和维权状态查询 |
| | | List<TaoBaoWeiQuanOrder> selectListByOrderIdAndState(@Param("orderId") String orderId, |
| | | @Param("state") String state); |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | @Table("yeshi_ec_common_order")
|
| | | public class CommonOrder {
|
| | |
|
| | | // 订单状态 1-付款,成功 2-结算(已收货) 3-维权 4-失效
|
| | | // 订单状态 1-付款,成功 2-结算(已收货) 3-维权 4-失效
|
| | | public final static int STATE_FK = 1;
|
| | | public final static int STATE_JS = 2;
|
| | | public final static int STATE_WQ = 3;
|
| | | public final static int STATE_SX = 4;
|
| | | |
| | |
|
| | | // 订单红包类型图片
|
| | | public final static String TYPE_FANLI = "http://ec-1255749512.file.myqcloud.com/resource/order/icon_fanli.png";
|
| | | public final static String TYPE_INVITE = "http://ec-1255749512.file.myqcloud.com/resource/order/icon_invite.png";
|
| | | public final static String TYPE_SHARE = "http://ec-1255749512.file.myqcloud.com/resource/order/icon_share.png";
|
| | | |
| | | |
| | |
|
| | | @Column(name = "co_id")
|
| | | private Long id;
|
| | |
|
| | |
| | | // 下单时间-第三方创建时间
|
| | | @Column(name = "co_third_create_time")
|
| | | private Date thirdCreateTime;
|
| | | |
| | |
|
| | | // 收货时间-结算时间
|
| | | @Column(name = "co_settle_time")
|
| | | private Date settleTime;
|
| | |
|
| | | @Column(name = "co_order_by")
|
| | | private Integer orderBy;// 子订单的排序值
|
| | |
|
| | | // 创建时间
|
| | | @Column(name = "co_create_time")
|
| | |
| | | // 更新时间
|
| | | @Column(name = "co_update_time")
|
| | | private Date updateTime;
|
| | | |
| | |
|
| | | public CommonOrder() {
|
| | |
|
| | | }
|
| | | |
| | |
|
| | | public CommonOrder(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
| | | this.settleTime = settleTime;
|
| | | }
|
| | |
|
| | | public Integer getOrderBy() {
|
| | | return orderBy;
|
| | | }
|
| | |
|
| | | public void setOrderBy(Integer orderBy) {
|
| | | this.orderBy = orderBy;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
| | | </association> |
| | | |
| | | <association property="parent" column="hb_pid" |
| | | javaType="com.yeshi.fanli.entity.push.PushGoods"> |
| | | javaType="com.yeshi.fanli.entity.bus.user.HongBaoV2"> |
| | | <id column="hb_pid" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | |
| | |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_hongbao_v2 where hb_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | |
| | | <select id="listChildrenById" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_hongbao_v2 where hb_pid = #{0} |
| | | </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" |
| | |
| | | <result column="co_third_create_time" property="thirdCreateTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP" /> |
| | | <result column="co_order_by" property="orderBy" jdbcType="INTEGER" /> |
| | | <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | |
| | |
| | | <association property="commonOrderGoods" column="co_order_goods_id" |
| | | javaType="com.yeshi.fanli.entity.order.CommonOrderGoods"> |
| | | <id column="co_order_goods_id" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | </resultMap> |
| | | |
| | | |
| | | <resultMap id="BaseDetailResultMap" type="com.yeshi.fanli.entity.order.CommonOrder"> |
| | | <id column="co_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="co_order_no" property="orderNo" jdbcType="VARCHAR" /> |
| | | <result column="co_source_type" property="sourceType" jdbcType="INTEGER" /> |
| | | <result column="co_source_position" property="sourcePosition" |
| | | jdbcType="VARCHAR" /> |
| | | <result column="co_count" property="count" jdbcType="INTEGER" /> |
| | | <result column="co_state" property="state" jdbcType="INTEGER" /> |
| | | <result column="co_estimate" property="estimate" jdbcType="DECIMAL" /> |
| | | <result column="co_eIncome" property="eIncome" jdbcType="DECIMAL" /> |
| | | <result column="co_payment" property="payment" jdbcType="DECIMAL" /> |
| | | <result column="co_settlement" property="settlement" jdbcType="DECIMAL" /> |
| | | <result column="co_third_create_time" property="thirdCreateTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP" /> |
| | | <result column="co_order_by" property="orderBy" jdbcType="INTEGER" /> |
| | | <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | |
| | | <association property="userInfo" column="co_uid" |
| | | javaType="com.yeshi.fanli.entity.bus.user.UserInfo"> |
| | | <id column="co_uid" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | |
| | | <association property="commonOrderGoods" resultMap="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.BaseResultMap"> |
| | | |
| | | </association> |
| | | </resultMap> |
| | | |
| | |
| | | <result column="co_third_create_time" property="thirdCreateTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP" /> |
| | | <result column="co_order_by" property="orderBy" jdbcType="INTEGER" /> |
| | | <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | |
| | |
| | | |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List">co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_create_time,co_update_time |
| | | <sql id="Base_Column_List">co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_order_by,co_create_time,co_update_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | |
| | | count(co_id) from yeshi_ec_common_order where co_order_no=#{orderNO} |
| | | and co_source_type=#{orderType} |
| | | </select> |
| | | |
| | | <select id="selectByOrderNoAndOrderTypeAndOrderBy" resultMap="BaseResultMap"> |
| | | select |
| | | * from yeshi_ec_common_order where co_order_no=#{orderNo} |
| | | and |
| | | co_source_type=#{orderType} and co_order_by=#{orderBy} |
| | | </select> |
| | | |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_common_order where co_id = #{id,jdbcType=BIGINT}</delete> |
| | | yeshi_ec_common_order where co_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.order.CommonOrder" |
| | | useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_common_order |
| | | (co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_create_time,co_update_time) |
| | |
| | | <if test="settlement != null">co_settlement,</if> |
| | | <if test="thirdCreateTime != null">co_third_create_time,</if> |
| | | <if test="settleTime != null">co_settle_time,</if> |
| | | <if test="orderBy != null">co_order_by,</if> |
| | | <if test="createTime != null">co_create_time,</if> |
| | | <if test="updateTime != null">co_update_time,</if> |
| | | </trim> |
| | |
| | | <if test="settlement != null">#{settlement,jdbcType=DECIMAL},</if> |
| | | <if test="thirdCreateTime != null">#{thirdCreateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="settleTime != null">#{settleTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="orderBy != null">#{orderBy,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | |
| | | #{payment,jdbcType=DECIMAL},co_settlement = |
| | | #{settlement,jdbcType=DECIMAL},co_third_create_time = |
| | | #{thirdCreateTime,jdbcType=TIMESTAMP},co_settle_time = |
| | | #{settleTime,jdbcType=TIMESTAMP},co_create_time = |
| | | #{settleTime,jdbcType=TIMESTAMP},co_order_by = |
| | | #{orderBy,jdbcType=INTEGER},co_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},co_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} where co_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | |
| | | <if test="thirdCreateTime != null">co_third_create_time=#{thirdCreateTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="settleTime != null">co_settle_time=#{settleTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="orderBy != null">co_order_by=#{orderBy,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">co_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">co_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | |
| | | <select id="listGroupOrderNoByUid" resultMap="ResultMap"> |
| | | SELECT COALESCE(SUM(th.`hb_money`),0)AS totalMoney,tc.*,th.hb_state AS |
| | | hongBaoState, th.hb_type AS hongBaoType, |
| | | th.hb_get_time AS accountTime,th.hb_get_time AS accountTime,th.hb_pre_get_time AS |
| | | th.hb_get_time AS |
| | | accountTime,th.hb_get_time AS accountTime,th.hb_pre_get_time AS |
| | | preAccountTime |
| | | FROM yeshi_ec_common_order tc |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | LEFT JOIN |
| | | yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN |
| | | yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | th.`hb_pid` = tr.`ho_hongbao_id` ) |
| | | WHERE th.`hb_uid` = #{uid} |
| | | <if test="state != null and state == 1"> <!-- 未到账 --> |
| | |
| | | DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1 |
| | | </if> |
| | | GROUP BY tc.`co_order_no`,tc.co_source_type |
| | | ORDER BY tc.co_create_time DESC |
| | | ORDER BY tc.co_create_time |
| | | DESC |
| | | LIMIT ${start},${count} |
| | | </select> |
| | | |
| | | <select id="countGroupOrderNoByUid" resultType="java.lang.Long"> |
| | | SELECT IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0) |
| | | FROM yeshi_ec_common_order tc |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON |
| | | tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_v2 th ON |
| | | (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | th.`hb_pid` = tr.`ho_hongbao_id` ) |
| | | WHERE th.`hb_uid` = #{uid} |
| | | <if test="state != null and state == 1"> <!-- 未到账 --> |
| | |
| | | SELECT COALESCE(SUM(tc.`co_settlement`),0)AS |
| | | totalSettlement,COALESCE(SUM(tc.`co_count`),0)AS |
| | | totalCount,tc.`co_source_type`,tc.`co_order_no`,tg.* |
| | | FROM yeshi_ec_common_order_goods tg |
| | | LEFT JOIN yeshi_ec_common_order tc ON tc.`co_order_goods_id` = tg.`cog_id` |
| | | FROM |
| | | yeshi_ec_common_order_goods tg |
| | | LEFT JOIN yeshi_ec_common_order tc ON |
| | | tc.`co_order_goods_id` = tg.`cog_id` |
| | | WHERE |
| | | <foreach collection="list" item="item" separator=" OR "> |
| | | (tc.`co_source_type` = #{item.sourceType,jdbcType=INTEGER} AND |
| | |
| | | SELECT IFNULL(COUNT(DISTINCT |
| | | tc.`co_order_no`,tc.`co_source_type`),0) AS self,0 AS shared,0 AS |
| | | invite FROM yeshi_ec_common_order tc |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_order |
| | | tr ON tr.`ho_order_id` = tc.`co_id` |
| | | LEFT |
| | | JOIN yeshi_ec_hongbao_v2 th ON tr.`ho_hongbao_id` = th.`hb_id` |
| | | JOIN yeshi_ec_hongbao_v2 th ON |
| | | tr.`ho_hongbao_id` = th.`hb_id` |
| | | WHERE |
| | | th.`hb_uid` = ${uid} |
| | | AND (th.`hb_type` = 1 OR th.`hb_type` = 2) |
| | | AND |
| | | (th.`hb_type` = 1 OR th.`hb_type` = 2) |
| | | <if test="day != null and day == 1"> |
| | | AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW()) |
| | | </if> |
| | |
| | | SELECT 0 AS self, IFNULL(COUNT(DISTINCT |
| | | tc.`co_order_no`,tc.`co_source_type`),0) AS shared,0 AS invite FROM |
| | | yeshi_ec_common_order tc |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON |
| | | tr.`ho_order_id` = tc.`co_id` |
| | | LEFT |
| | | JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | JOIN yeshi_ec_hongbao_v2 th ON |
| | | (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | th.`hb_pid` = tr.`ho_hongbao_id` ) |
| | | WHERE th.`hb_uid` = ${uid} |
| | | AND (th.`hb_type` = 20 OR th.`hb_type` = 21 OR th.`hb_type` = 22) |
| | | AND (th.`hb_type` = 20 OR th.`hb_type` = 21 |
| | | OR th.`hb_type` = 22) |
| | | <if test="day != null and day == 1"> |
| | | AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW()) |
| | | </if> |
| | |
| | | SELECT 0 AS self,0 AS shared,IFNULL(COUNT(DISTINCT |
| | | tc.`co_order_no`,tc.`co_source_type`),0) AS invite FROM |
| | | yeshi_ec_common_order tc |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON |
| | | tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_v2 th ON |
| | | (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | th.`hb_pid` = tr.`ho_hongbao_id` ) |
| | | WHERE th.`hb_uid` = ${uid} |
| | | AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7) |
| | | AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR |
| | | th.`hb_type` = 7) |
| | | <if test="day != null and day == 1"> |
| | | AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW()) |
| | | </if> |
| | |
| | | tc.`co_order_no`,tc.`co_source_type`),0) AS valid,0 AS proces,0 AS |
| | | Invalid |
| | | FROM yeshi_ec_common_order tc |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | LEFT JOIN yeshi_ec_hongbao_order |
| | | tr ON tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_v2 th ON |
| | | (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | th.`hb_pid` = tr.`ho_hongbao_id` ) |
| | | WHERE th.`hb_uid` = #{uid} AND |
| | | (tc.`co_state` = 1 OR tc.`co_state` = 2) |
| | |
| | | tc.`co_order_no`,tc.`co_source_type`),0) AS proces,0 AS Invalid |
| | | FROM |
| | | yeshi_ec_common_order tc |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON |
| | | tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_v2 th ON |
| | | (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | th.`hb_pid` = tr.`ho_hongbao_id` ) |
| | | WHERE th.`hb_uid` = #{uid} AND |
| | | tc.`co_state` =3 |
| | |
| | | tc.`co_order_no`,tc.`co_source_type`),0) AS Invalid |
| | | FROM |
| | | yeshi_ec_common_order tc |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON |
| | | tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_v2 th ON |
| | | (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | th.`hb_pid` = tr.`ho_hongbao_id` ) |
| | | WHERE th.`hb_uid`= #{uid} AND |
| | | tc.`co_state` = 4 |
| | |
| | | <select id="countBonusOrderMoney" resultType="java.math.BigDecimal"> |
| | | SELECT COALESCE(SUM(th.`hb_money`),0)AS totalmoney FROM |
| | | yeshi_ec_common_order tc |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON |
| | | tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_v2 th ON |
| | | (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | th.`hb_pid` = tr.`ho_hongbao_id` ) |
| | | WHERE <![CDATA[tc.`co_state` <> 4]]> |
| | | <if test="uid != null"> |
| | |
| | | <select id="listBonusOrder" resultMap="ResultMap"> |
| | | SELECT COALESCE(SUM(th.`hb_money`),0)AS totalMoney,tc.*,th.hb_state AS |
| | | hongBaoState, th.hb_type AS hongBaoType, |
| | | th.hb_get_time AS accountTime,th.hb_get_time AS accountTime,th.hb_pre_get_time AS |
| | | th.hb_get_time AS |
| | | accountTime,th.hb_get_time AS accountTime,th.hb_pre_get_time AS |
| | | preAccountTime |
| | | FROM yeshi_ec_common_order tc |
| | | LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | LEFT JOIN |
| | | yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` |
| | | LEFT JOIN |
| | | yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR |
| | | th.`hb_pid` = tr.`ho_hongbao_id` ) |
| | | WHERE th.`hb_uid` = #{uid} |
| | | <if test="type != null and type == 1"> <!-- 自购订单 --> |
| | |
| | | DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1 |
| | | </if> |
| | | GROUP BY tc.`co_order_no`,tc.co_source_type |
| | | ORDER BY tc.co_create_time DESC |
| | | ORDER BY tc.co_create_time |
| | | DESC |
| | | LIMIT ${start},${count} |
| | | </select> |
| | | |
| | |
| | | <id column="ho_hongbao_id" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | |
| | | <association property="commonOrderGoods" column="ho_order_id" |
| | | <association property="commonOrder" column="ho_order_id" |
| | | javaType="com.yeshi.fanli.entity.order.CommonOrder"> |
| | | <id column="ho_order_id" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | |
| | | </resultMap> |
| | | |
| | | |
| | | <resultMap id="BaseDetailResultMap" type="com.yeshi.fanli.entity.order.HongBaoOrder"> |
| | | <id column="ho_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="ho_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | |
| | | <association property="hongBaoV2" |
| | | resultMap="com.yeshi.fanli.dao.mybatis.HongBaoV2Mapper.BaseResultMap"> |
| | | </association> |
| | | |
| | | <association property="commonOrder" |
| | | resultMap="com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper.BaseDetailResultMap"> |
| | | </association> |
| | | |
| | | </resultMap> |
| | | |
| | | |
| | | |
| | | <sql id="Base_Column_List"> |
| | | ho_id,ho_hongbao_id,ho_order_id,ho_create_time |
| | | </sql> |
| | |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_hongbao_order where ho_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <select id="selectByCommonOrderId" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_hongbao_order where ho_order_id = #{0} |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <select id="listFanLiOrder" resultMap="BaseDetailResultMap"> |
| | | SELECT * FROM (SELECT * |
| | | FROM yeshi_ec_hongbao_v2 h WHERE h.`hb_uid`=#{uid} AND h.`hb_type`=1 |
| | | ORDER BY h.`hb_create_time` DESC LIMIT #{start},#{count}) hh LEFT JOIN |
| | | yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id`=hh.hb_id |
| | | LEFT JOIN |
| | | yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` LEFT |
| | | JOIN |
| | | yeshi_ec_common_order_goods g ON |
| | | g.`cog_id`=co.`co_order_goods_id` |
| | | </select> |
| | | |
| | | |
| | | <select id="countFanLiOrder" resultType="java.lang.Long" |
| | | parameterType="java.lang.Long"> |
| | | |
| | | SELECT COUNT(h.`hb_id`) FROM yeshi_ec_hongbao_v2 h WHERE |
| | | h.`hb_uid`=#{0} AND |
| | | h.`hb_type`=1 |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_hongbao_order where ho_id = #{id,jdbcType=BIGINT}</delete> |
| | | 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 |
| | | (ho_id,ho_hongbao_id,ho_order_id,ho_create_time) values |
| | |
| | | package com.yeshi.fanli.service.impl.hongbao;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
| | | return getShareRate(System.currentTimeMillis());
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getFirstInviteRate(int urank) {
|
| | | return getFirstInviteRate(urank, System.currentTimeMillis());
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getFirstInviteRate(int urank, long time) {
|
| | | String key = "sale_6_" + urank;
|
| | |
|
| | | 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 getSecondInviteRate(int urank) {
|
| | | return getSecondInviteRate(urank, System.currentTimeMillis());
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getSecondInviteRate(int urank, long time) {
|
| | | String key = "sale_7_" + urank;
|
| | |
|
| | | HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
|
| | | if (hongBaoManage == null)
|
| | | hongBaoManage = hongBaoManageMapper.selectByKey(key);
|
| | | if (hongBaoManage != null)
|
| | | return new BigDecimal(hongBaoManage.getValue());
|
| | | LogHelper.error("获取返利分成比例出错");
|
| | | return new BigDecimal(0);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getFirstShareRate(int urank) {
|
| | | String key = "share_21_" + urank;
|
| | | HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, System.currentTimeMillis());
|
| | | if (hongBaoManage == null)
|
| | | hongBaoManage = hongBaoManageMapper.selectByKey(key);
|
| | | if (hongBaoManage != null)
|
| | | return new BigDecimal(hongBaoManage.getValue());
|
| | | LogHelper.error("获取返利分成比例出错");
|
| | | return new BigDecimal(0);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getFirstShareRate(int urank, long time) {
|
| | | String key = "share_21_" + urank;
|
| | | HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
|
| | | if (hongBaoManage == null)
|
| | | hongBaoManage = hongBaoManageMapper.selectByKey(key);
|
| | | if (hongBaoManage != null)
|
| | | return new BigDecimal(hongBaoManage.getValue());
|
| | | LogHelper.error("获取返利分成比例出错");
|
| | | return new BigDecimal(0);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getSecondShareRate(int urank) {
|
| | | String key = "share_22_" + urank;
|
| | | HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, System.currentTimeMillis());
|
| | | if (hongBaoManage == null)
|
| | | hongBaoManage = hongBaoManageMapper.selectByKey(key);
|
| | | if (hongBaoManage != null)
|
| | | return new BigDecimal(hongBaoManage.getValue());
|
| | | LogHelper.error("获取返利分成比例出错");
|
| | | return new BigDecimal(0);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getSecondShareRate(int urank, long time) {
|
| | | String key = "share_22_" + urank;
|
| | | HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
|
| | | if (hongBaoManage == null)
|
| | | hongBaoManage = hongBaoManageMapper.selectByKey(key);
|
| | | if (hongBaoManage != null)
|
| | | return new BigDecimal(hongBaoManage.getValue());
|
| | | LogHelper.error("获取返利分成比例出错");
|
| | | return new BigDecimal(0);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.hongbao;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Calendar;
|
| | | import java.util.Collections;
|
| | | import java.util.Comparator;
|
| | | import java.util.Date;
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.order.OrderItemMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.OrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBao;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.CommonOrderGoods;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.HongBaoException;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | |
|
| | | @Service
|
| | |
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper;
|
| | |
|
| | | @Override
|
| | | public int insert(HongBaoV2 record) {
|
| | |
| | | if (hb.getOrder() != null) {
|
| | | orderId = hb.getOrder().getOrderId();
|
| | | // 查询同一订单号的非子红包
|
| | |
|
| | | } else
|
| | | orderId = hb.getOrderId();
|
| | |
|
| | |
| | | if (list.size() <= 0)
|
| | | return;
|
| | | List<TaoBaoOrder> orderList = taoBaoOrderMapper.selectTaoBaoOrderByOrderId(orderId);
|
| | |
|
| | | if (orderList == null || orderList.size() < list.size()) {
|
| | | System.out.println("红包数与订单数不对应");
|
| | | return;
|
| | | }
|
| | |
|
| | | // 加入排序值
|
| | | for (int i = 0; i < orderList.size(); i++) {
|
| | | orderList.get(i).setOrderBy(i + 1);
|
| | | }
|
| | |
|
| | | // 按照auctionId,payMoney排序
|
| | |
| | | commonOrder.setCreateTime(new Date(list.get(i).getCreatetime()));
|
| | |
|
| | | // TODO 维权判断
|
| | | List<TaoBaoWeiQuanOrder> weiQuanList = taoBaoWeiQuanOrderMapper.selectListByOrderIdAndState(orderId,
|
| | | "维权成功");
|
| | | if (weiQuanList != null && weiQuanList.size() > 0)
|
| | | commonOrder.setState(CommonOrder.STATE_WQ);
|
| | |
|
| | | commonOrderMapper.insertSelective(commonOrder);
|
| | |
|
| | | // 插入红包
|
| | |
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void addHongBao(CommonOrder commonOrder, int type) throws HongBaoException {
|
| | | if (commonOrder == null || commonOrder.getId() == null || commonOrder.getUserInfo() == null)
|
| | | throw new HongBaoException(1, "订单信息不完整");
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
|
| | | if (hongBaoOrder == null) {
|
| | | if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
|
| | | BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
|
| | |
|
| | | } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | |
|
| | | } else
|
| | | throw new HongBaoException(2, "type错误");
|
| | |
|
| | | saveHongBao(commonOrder, type);
|
| | | } else {
|
| | |
|
| | | updateHongBao(hongBaoOrder, commonOrder, type);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | private void updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type) throws HongBaoException {
|
| | | System.out.println(commonOrder.getOrderNo());
|
| | | HongBaoV2 oldHongBao = hongBaoV2Mapper.selectByPrimaryKey(hongBaoOrder.getHongBaoV2().getId());
|
| | | if (oldHongBao == null)
|
| | | throw new HongBaoException(10, "红包对象不存在");
|
| | | // 已经失效或者已经领取的红包不做处理
|
| | | if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | return;
|
| | |
|
| | | if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
|
| | | BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
|
| | | HongBaoV2 hongBao = new HongBaoV2(hongBaoOrder.getHongBaoV2().getId());
|
| | | hongBao.setUpdateTime(new Date());
|
| | | // 更改状态与资金
|
| | | if (commonOrder.getState() == CommonOrder.STATE_FK) {
|
| | | hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS) {
|
| | | hongBao.setState(HongBaoV2.STATE_KELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
|
| | | hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L));
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
|
| | | hongBao.setState(HongBaoV2.STATE_SHIXIAO);
|
| | | hongBao.setMoney(new BigDecimal(0));
|
| | | }
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
|
| | |
|
| | | // 获取子红包
|
| | | List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
|
| | | if (children != null)
|
| | | for (HongBaoV2 child : children) {
|
| | | HongBaoV2 childUpdate = new HongBaoV2(child.getId());
|
| | | childUpdate.setState(hongBao.getState());
|
| | | childUpdate.setUpdateTime(new Date());
|
| | | BigDecimal rate = null;
|
| | | if (child.getType() == HongBaoV2.TYPE_YIJI) {// 一级分享赚
|
| | | rate = hongBaoManageService.getFirstInviteRate(child.getUrank(),
|
| | | commonOrder.getCreateTime().getTime());
|
| | | } else if (child.getType() == HongBaoV2.TYPE_ERJI) {// 二级分享赚
|
| | | rate = hongBaoManageService.getSecondInviteRate(child.getUrank(),
|
| | | commonOrder.getCreateTime().getTime());
|
| | | }
|
| | |
|
| | | // 以实际收入为准计算预估收益
|
| | | if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | childUpdate.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), rate.divide(new BigDecimal(100))));
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(commonOrder.getSettleTime());
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | | childUpdate.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
|
| | | calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
|
| | | "yyyy-M-dd")));
|
| | | } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
|
| | | childUpdate.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), rate.divide(new BigDecimal(100))));
|
| | | }
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
|
| | | }
|
| | |
|
| | | } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | | BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
|
| | | HongBaoV2 hongBao = new HongBaoV2(hongBaoOrder.getHongBaoV2().getId());
|
| | | hongBao.setUpdateTime(new Date());
|
| | | // 更改状态与资金
|
| | | if (commonOrder.getState() == CommonOrder.STATE_FK) {
|
| | | hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS) {
|
| | | hongBao.setState(HongBaoV2.STATE_KELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(commonOrder.getSettleTime());
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | | hongBao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
|
| | | calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd")));
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
|
| | | hongBao.setState(HongBaoV2.STATE_SHIXIAO);
|
| | | hongBao.setMoney(new BigDecimal(0));
|
| | | }
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
|
| | |
|
| | | // 获取子红包
|
| | | List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
|
| | | if (children != null)
|
| | | for (HongBaoV2 child : children) {
|
| | | HongBaoV2 childUpdate = new HongBaoV2(child.getId());
|
| | | // 统一设置状态
|
| | | childUpdate.setState(hongBao.getState());
|
| | | childUpdate.setUpdateTime(new Date());
|
| | | BigDecimal rate = null;
|
| | | if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级分享赚
|
| | | rate = hongBaoManageService.getFirstShareRate(child.getUrank(),
|
| | | commonOrder.getCreateTime().getTime());
|
| | | } else if (child.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级分享赚
|
| | | rate = hongBaoManageService.getSecondShareRate(child.getUrank(),
|
| | | commonOrder.getCreateTime().getTime());
|
| | | }
|
| | |
|
| | | // 以实际收入为准计算预估收益
|
| | | if (CommonOrder.STATE_JS == commonOrder.getState()) {
|
| | | childUpdate.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), rate.divide(new BigDecimal(100))));
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(commonOrder.getSettleTime());
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | | childUpdate.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
|
| | | calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
|
| | | "yyyy-M-dd")));
|
| | | } else if (CommonOrder.STATE_FK == commonOrder.getState()) {
|
| | | if (commonOrder.getOrderNo().equalsIgnoreCase("314134177659155087"))
|
| | | System.out.println("");
|
| | |
|
| | | childUpdate.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), rate.divide(new BigDecimal(100))));
|
| | | }
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
|
| | | }
|
| | | } else
|
| | | throw new HongBaoException(2, "type错误");
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | private void saveHongBao(CommonOrder commonOrder, int type) throws HongBaoException {
|
| | | if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
|
| | | BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
|
| | | HongBaoV2 hongBao = new HongBaoV2();
|
| | | hongBao.setUserInfo(commonOrder.getUserInfo());
|
| | | hongBao.setCreateTime(new Date());
|
| | | hongBao.setType(HongBaoV2.TYPE_ZIGOU);
|
| | | hongBao.setVersion(2);
|
| | | if (commonOrder.getState() == CommonOrder.STATE_FK) {
|
| | | hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS) {
|
| | | hongBao.setState(HongBaoV2.STATE_KELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
|
| | | hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L));
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
|
| | | hongBao.setState(HongBaoV2.STATE_SHIXIAO);
|
| | | hongBao.setMoney(new BigDecimal(0));
|
| | | } else {
|
| | | throw new HongBaoException(3, "维权订单不能创建红包");
|
| | | }
|
| | | UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
|
| | | hongBao.setUrank(user.getRank());
|
| | | hongBaoV2Mapper.insertSelective(hongBao);
|
| | | // 添加红包与订单的映射
|
| | | HongBaoOrder hongBaoOrder = new HongBaoOrder();
|
| | | hongBaoOrder.setCommonOrder(commonOrder);
|
| | | hongBaoOrder.setCreateTime(new Date());
|
| | | hongBaoOrder.setHongBaoV2(hongBao);
|
| | | hongBaoOrderMapper.insertSelective(hongBaoOrder);
|
| | |
|
| | | UserInfo boss = threeSaleSerivce.getBoss(user.getId());
|
| | | if (boss != null && hongBao.getState() != HongBaoV2.STATE_SHIXIAO) {// 1级BOSS存在且红包未失效
|
| | |
|
| | | // 插入一级子红包
|
| | | BigDecimal firstRate = hongBaoManageService
|
| | | .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
|
| | | if (firstRate.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | HongBaoV2 firstHongbao = new HongBaoV2();
|
| | | firstHongbao.setUserInfo(boss);
|
| | | firstHongbao.setUrank(boss.getRank());
|
| | | firstHongbao.setParent(hongBao);
|
| | | firstHongbao.setCreateTime(new Date());
|
| | | firstHongbao.setType(HongBaoV2.TYPE_YIJI);
|
| | | firstHongbao.setVersion(2);
|
| | | firstHongbao.setState(hongBao.getState());
|
| | |
|
| | | if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | firstHongbao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), firstRate.divide(new BigDecimal(100))));
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(commonOrder.getSettleTime());
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | | firstHongbao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
|
| | | calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
|
| | | "yyyy-M-dd")));
|
| | | } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
|
| | | firstHongbao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), firstRate.divide(new BigDecimal(100))));
|
| | | }
|
| | | hongBaoV2Mapper.insertSelective(firstHongbao);
|
| | |
|
| | | // 插入二级子红包
|
| | | boss = threeSaleSerivce.getBoss(boss.getId());
|
| | | if (boss != null) {// 二级BOSS存在
|
| | | BigDecimal secondRate = hongBaoManageService
|
| | | .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
|
| | | if (secondRate.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | HongBaoV2 secondHongbao = new HongBaoV2();
|
| | | secondHongbao.setUserInfo(boss);
|
| | | secondHongbao.setUrank(boss.getRank());
|
| | | secondHongbao.setParent(hongBao);
|
| | | secondHongbao.setCreateTime(new Date());
|
| | | secondHongbao.setType(HongBaoV2.TYPE_ERJI);
|
| | | secondHongbao.setVersion(2);
|
| | | secondHongbao.setState(hongBao.getState());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | firstHongbao.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(),
|
| | | secondRate.divide(new BigDecimal(100))));
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(commonOrder.getSettleTime());
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | | secondHongbao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
|
| | | calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
|
| | | "yyyy-M-dd")));
|
| | | } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
|
| | | secondHongbao.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(),
|
| | | secondRate.divide(new BigDecimal(100))));
|
| | | }
|
| | | hongBaoV2Mapper.insertSelective(secondHongbao);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | | // 分享赚不加入失效的订单
|
| | | if (commonOrder.getState() == CommonOrder.STATE_SX || commonOrder.getState() == CommonOrder.STATE_WQ)
|
| | | return;
|
| | | // 分享赚
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
|
| | | HongBaoV2 hongBao = new HongBaoV2();
|
| | | hongBao.setCreateTime(new Date());
|
| | | hongBao.setType(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | hongBao.setVersion(2);
|
| | | if (commonOrder.getState() == CommonOrder.STATE_FK) {
|
| | | hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), shareRate.divide(new BigDecimal(100))));
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS) {
|
| | | hongBao.setState(HongBaoV2.STATE_KELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), shareRate.divide(new BigDecimal(100))));
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(commonOrder.getSettleTime());
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | | hongBao.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
|
| | | calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd")));
|
| | | }
|
| | | UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
|
| | | hongBao.setUrank(user.getRank());
|
| | | hongBao.setUserInfo(user);
|
| | | hongBaoV2Mapper.insertSelective(hongBao);
|
| | | // 插入红包与订单映射
|
| | | HongBaoOrder hongBaoOrder = new HongBaoOrder();
|
| | | hongBaoOrder.setCommonOrder(commonOrder);
|
| | | hongBaoOrder.setCreateTime(new Date());
|
| | | hongBaoOrder.setHongBaoV2(hongBao);
|
| | | hongBaoOrderMapper.insertSelective(hongBaoOrder);
|
| | | } else
|
| | | throw new HongBaoException(2, "type错误");
|
| | | }
|
| | | }
|
| | |
| | | import java.math.BigDecimal;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | |
| | |
|
| | | import org.apache.commons.beanutils.PropertyUtils;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.CommonOrderGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonOrderGoodsFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderGoodsVO;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderVO;
|
| | |
|
| | |
|
| | | @Service
|
| | | public class CommonOrderServiceImpl implements CommonOrderService {
|
| | | |
| | |
|
| | | @Resource
|
| | | private CommonOrderMapper commonOrderMapper;
|
| | | |
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper;
|
| | | |
| | |
|
| | | @Resource
|
| | | private CommonOrderGoodsMapper commonOrderGoodsMapper;
|
| | |
|
| | | @Override
|
| | | public int insert(CommonOrder record) {
|
| | | return commonOrderMapper.insert(record);
|
| | |
| | | public CommonOrder selectByPrimaryKey(Long id) {
|
| | | return commonOrderMapper.selectByPrimaryKey(id);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public List<CommonOrderVO> listGroupOrderNoByUid(long start, int count, Long uid, Integer state, |
| | | Integer type,Integer orderState, String orderNo, String startTime,String endTime, |
| | | Integer dateType) throws CommonOrderException{
|
| | | return commonOrderMapper.listGroupOrderNoByUid(start, count, uid, state, type, orderState,
|
| | | orderNo, startTime, endTime, dateType);
|
| | | public List<CommonOrderVO> listGroupOrderNoByUid(long start, int count, Long uid, Integer state, Integer type,
|
| | | Integer orderState, String orderNo, String startTime, String endTime, Integer dateType)
|
| | | throws CommonOrderException {
|
| | | return commonOrderMapper.listGroupOrderNoByUid(start, count, uid, state, type, orderState, orderNo, startTime,
|
| | | endTime, dateType);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public long countGroupOrderNoByUid(Long uid,Integer state, Integer type, Integer orderState, |
| | | String orderNo, String startTime,String endTime, Integer dateType) throws CommonOrderException{
|
| | | return commonOrderMapper.countGroupOrderNoByUid(uid, state, type, orderState, orderNo,
|
| | | startTime, endTime, dateType);
|
| | | public long countGroupOrderNoByUid(Long uid, Integer state, Integer type, Integer orderState, String orderNo,
|
| | | String startTime, String endTime, Integer dateType) throws CommonOrderException {
|
| | | return commonOrderMapper.countGroupOrderNoByUid(uid, state, type, orderState, orderNo, startTime, endTime,
|
| | | dateType);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public List<CommonOrderVO> getOrderByUid (Integer page, Long uid, Integer state, Integer type,
|
| | | Integer orderState, String orderNo, String startTime, String endTime, Integer dateType) throws CommonOrderException {
|
| | | |
| | | public List<CommonOrderVO> getOrderByUid(Integer page, Long uid, Integer state, Integer type, Integer orderState,
|
| | | String orderNo, String startTime, String endTime, Integer dateType) throws CommonOrderException {
|
| | |
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | | |
| | | List<CommonOrderVO> listOrder = listGroupOrderNoByUid((page - 1) * pageSize, pageSize, uid, |
| | | state, type, orderState, orderNo, startTime, endTime, dateType);
|
| | | |
| | |
|
| | | List<CommonOrderVO> listOrder = listGroupOrderNoByUid((page - 1) * pageSize, pageSize, uid, state, type,
|
| | | orderState, orderNo, startTime, endTime, dateType);
|
| | |
|
| | | // 订单信息为空
|
| | | if (listOrder == null || listOrder.size() == 0) {
|
| | | listOrder = new ArrayList<CommonOrderVO>();
|
| | | return listOrder;
|
| | | }
|
| | | |
| | |
|
| | | // 商品信息
|
| | | List<CommonOrderVO> listGoods = commonOrderMapper.listByOrderNoAndType(listOrder);
|
| | | // 订单商品为空
|
| | | if (listGoods ==null || listGoods.size() == 0) {
|
| | | return listOrder; |
| | | if (listGoods == null || listGoods.size() == 0) {
|
| | | return listOrder;
|
| | | }
|
| | | |
| | |
|
| | | // 数据加工重新组织
|
| | | listDataFactory(listOrder, listGoods);
|
| | | |
| | |
|
| | | return listOrder;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public Map<String, BigDecimal> countOrderByHongBaoType(Long uid, Integer day) {
|
| | | return commonOrderMapper.countOrderByHongBaoType(uid, day);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public long countOrder(Long uid,Integer type, Integer day) {
|
| | | public long countOrder(Long uid, Integer type, Integer day) {
|
| | | return commonOrderMapper.countBonusOrder(uid, type, day);
|
| | | }
|
| | |
|
| | |
| | | public BigDecimal countOrderMoney(Long uid, Integer type, Integer day) {
|
| | | return commonOrderMapper.countBonusOrderMoney(uid, type, day);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime,
|
| | | String endTime, Integer day) {
|
| | | return commonOrderMapper.countByUidAndOrderState(uid, type, startTime, endTime, day);
|
| | | public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime, String endTime,
|
| | | Integer day) {
|
| | | return commonOrderMapper.countByUidAndOrderState(uid, type, startTime, endTime, day);
|
| | | }
|
| | | |
| | | public void listDataFactory (List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods ) {
|
| | | |
| | | /* 组合商品信息 */
|
| | | for (CommonOrderVO commonOrder: listGoods) {
|
| | | |
| | |
|
| | | public void listDataFactory(List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods) {
|
| | |
|
| | | /* 组合商品信息 */
|
| | | for (CommonOrderVO commonOrder : listGoods) {
|
| | |
|
| | | CommonOrderGoods goods = commonOrder.getCommonOrderGoods();
|
| | | if (goods == null) {
|
| | | continue;
|
| | | }
|
| | | |
| | |
|
| | | String orderNo1 = commonOrder.getOrderNo();
|
| | | Integer sourceType = commonOrder.getSourceType();
|
| | | |
| | | for (CommonOrderVO order: listOrder) {
|
| | |
|
| | | for (CommonOrderVO order : listOrder) {
|
| | | String orderNo2 = order.getOrderNo();
|
| | | Integer sourceType2 = order.getSourceType();
|
| | | |
| | |
|
| | | // 来源、订单号相同
|
| | | if (sourceType.equals(sourceType2) && orderNo1.equals(orderNo2)) {
|
| | | // 加入商品信息
|
| | | List<CommonOrderGoodsVO> listOrderGoods = order.getListOrderGoods();
|
| | | |
| | |
|
| | | CommonOrderGoodsVO commonGoodsVO = new CommonOrderGoodsVO();
|
| | | try {
|
| | | PropertyUtils.copyProperties(commonGoodsVO, goods);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | |
|
| | | Integer hongBaoType = order.getHongBaoType();
|
| | | // 邀请订单信息保护
|
| | | if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType |
| | | || HongBaoV2.TYPE_ERJI == hongBaoType) {
|
| | | if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
|
| | | || HongBaoV2.TYPE_ERJI == hongBaoType) {
|
| | | Map<String, String> titleMap = new HashMap<String, String>();
|
| | | titleMap.put("content", "为保障用户隐私,商品信息已隐藏!");
|
| | | titleMap.put("fontColor", "#888888");
|
| | |
| | | commonGoodsVO.setTitle(null);
|
| | | commonGoodsVO.setGoodsTitle(titleMap);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | commonGoodsVO.setActualCount(commonOrder.getTotalCount() + "件");
|
| | | String settlement = commonOrder.getTotalSettlement().setScale(2, BigDecimal.ROUND_DOWN).toString();
|
| | | commonGoodsVO.setActualPay("实付款:¥" + settlement);
|
| | | |
| | |
|
| | | listOrderGoods.add(commonGoodsVO);
|
| | | |
| | |
|
| | | Integer orderType = commonOrder.getOrderType();
|
| | | if (orderType == null) {
|
| | | String shopType = commonGoodsVO.getShopType();
|
| | |
| | | commonOrder.setOrderType(1);
|
| | | } else if (CommonOrderGoodsVO.TYPE_TMALL.equalsIgnoreCase(shopType)) {
|
| | | commonOrder.setOrderType(2);
|
| | | } |
| | | }
|
| | | }
|
| | | |
| | |
|
| | | break;
|
| | | }
|
| | | } |
| | | }
|
| | | }
|
| | | |
| | |
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | | SimpleDateFormat formatday = new SimpleDateFormat("yyyy.MM.dd");
|
| | | |
| | | for (CommonOrderVO order: listOrder) {
|
| | |
|
| | | for (CommonOrderVO order : listOrder) {
|
| | | Date createTime = order.getCreateTime();
|
| | | if (createTime != null) {
|
| | | order.setObtainTime(createTime.getTime());
|
| | | }
|
| | | |
| | |
|
| | | Date thirdCreateTime = order.getThirdCreateTime();
|
| | | if (thirdCreateTime != null) {
|
| | | order.setDownTime("下单时间:" + format.format(thirdCreateTime));
|
| | | }
|
| | | |
| | |
|
| | | Date settleTime = order.getSettleTime();
|
| | | if (settleTime != null) {
|
| | | order.setReceiveTime("收货时间:" + format.format(settleTime));
|
| | | }
|
| | | |
| | | /* 订单状态 转换处理*/
|
| | |
|
| | | /* 订单状态 转换处理 */
|
| | | String orderStateContent = "";
|
| | | Map<String, String> orderStateMap = new HashMap<String, String>();
|
| | | |
| | |
|
| | | Integer hongBaoState = order.getHongBaoState();
|
| | | |
| | |
|
| | | Integer orderState = order.getState();
|
| | | if (CommonOrder.STATE_FK == orderState ) {
|
| | | if (CommonOrder.STATE_FK == orderState) {
|
| | | orderStateContent = "已付款";
|
| | | } else if (CommonOrder.STATE_JS == orderState) {
|
| | | orderStateContent = "已收货";
|
| | |
| | | orderStateContent = "未付款/已退款";
|
| | | } else if (CommonOrder.STATE_WQ == orderState) {
|
| | | orderStateContent = "已维权";
|
| | | |
| | | /* 订单维权 判断是否全部维权 */
|
| | | List<TaoBaoWeiQuanOrder> listWQ =
|
| | | taoBaoWeiQuanOrderMapper.selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
|
| | | |
| | |
|
| | | /* 订单维权 判断是否全部维权 */
|
| | | List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
|
| | |
|
| | | boolean isPart = false;// 默认失效
|
| | | |
| | | if (listWQ != null && listWQ.size() > 0) {
|
| | |
|
| | | if (listWQ != null && listWQ.size() > 0) {
|
| | | BigDecimal fanTotalMoney = new BigDecimal(0);
|
| | | for (TaoBaoWeiQuanOrder weiQuanOrder: listWQ) {
|
| | | for (TaoBaoWeiQuanOrder weiQuanOrder : listWQ) {
|
| | | BigDecimal fanMoney = weiQuanOrder.getFanMoney();
|
| | | if (fanMoney != null) {
|
| | | fanTotalMoney = MoneyBigDecimalUtil.add(fanTotalMoney, fanMoney);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (fanTotalMoney.compareTo(order.getHongBao()) < 0) {
|
| | | isPart = true;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (isPart) {
|
| | | hongBaoState = HongBaoV2.STATE_BUFENSHIXIAO; // 部分失效
|
| | | } else {
|
| | |
| | | orderStateMap.put("content", orderStateContent);
|
| | | orderStateMap.put("fontColor", "#666666");
|
| | | order.setOrderState(orderStateMap);
|
| | | |
| | |
|
| | | String hongbaoInfo = "";
|
| | | /* 订单返利类型 转换 */
|
| | | /* 订单返利类型 转换 */
|
| | | Integer hongBaoType = order.getHongBaoType();
|
| | | if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) {
|
| | | // 自购
|
| | | hongbaoInfo = "返利";
|
| | | order.setOrderOrigin("1");
|
| | | order.setHongBaoTypePic(CommonOrder.TYPE_FANLI);
|
| | | } else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType |
| | | } else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
|
| | | || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
|
| | | // 分享
|
| | | hongbaoInfo = "奖金";
|
| | | order.setOrderOrigin("2");
|
| | | order.setHongBaoTypePic(CommonOrder.TYPE_SHARE);
|
| | | } else if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType |
| | | } else if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
|
| | | || HongBaoV2.TYPE_ERJI == hongBaoType) {
|
| | | // 邀请
|
| | | hongbaoInfo = "奖金";
|
| | | order.setOrderOrigin("3");
|
| | | order.setHongBaoTypePic(CommonOrder.TYPE_INVITE);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | String hongBaoDate = null;
|
| | | String hongBaoState_Str = "";
|
| | | String hongbaoInfoFontColor = "#E5005C";
|
| | | |
| | |
|
| | | /* 红包状态 转换 */
|
| | | String stateContent = "";
|
| | | String stateFontColor = "#E5005C";
|
| | | Integer orderHongBaoState = null;
|
| | | |
| | |
|
| | | if (HongBaoV2.STATE_KELINGQU == hongBaoState || HongBaoV2.STATE_BUKELINGQU == hongBaoState) {
|
| | | orderHongBaoState = 1;
|
| | | stateContent = "未到账";
|
| | | hongBaoState_Str = "预估";
|
| | | |
| | |
|
| | | Date preAccountTime = order.getPreAccountTime();
|
| | | if (preAccountTime != null) {
|
| | | hongBaoDate = "预计到账时间:" + formatday.format(preAccountTime);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | } else if (HongBaoV2.STATE_YILINGQU == hongBaoState) {
|
| | | orderHongBaoState = 3;
|
| | | stateContent = "已到账";
|
| | | |
| | |
|
| | | Date accountTime = order.getAccountTime();
|
| | | if (accountTime != null) {
|
| | | hongBaoDate = "到账时间:" + formatday.format(accountTime);
|
| | | }
|
| | | |
| | |
|
| | | } else if (HongBaoV2.STATE_BUFENSHIXIAO == hongBaoState) {
|
| | | stateContent = "部分失效"; |
| | | stateContent = "部分失效";
|
| | | orderHongBaoState = 3;
|
| | | Date accountTime = order.getAccountTime();
|
| | | if (accountTime != null) {
|
| | | hongBaoDate = "到账时间:" + formatday.format(accountTime);
|
| | | }
|
| | | |
| | |
|
| | | } else if (HongBaoV2.STATE_SHIXIAO == hongBaoState) {
|
| | | orderHongBaoState = 4;
|
| | | stateContent = "已失效"; |
| | | stateContent = "已失效";
|
| | | hongbaoInfoFontColor = "#888888";
|
| | | }
|
| | | order.setHongBaoState(orderHongBaoState);
|
| | | order.setHongBaoDate(hongBaoDate);
|
| | | |
| | |
|
| | | Map<String, String> stateMap = new HashMap<String, String>();
|
| | | stateMap.put("content", stateContent);
|
| | | stateMap.put("fontColor", stateFontColor);
|
| | | order.setAccountState(stateMap);
|
| | | |
| | |
|
| | | hongbaoInfo = hongBaoState_Str + hongbaoInfo;
|
| | | |
| | |
|
| | | BigDecimal hongBao = order.getHongBao();
|
| | | if (hongBao == null) {
|
| | | hongBao = new BigDecimal(0);
|
| | |
| | | hongBaoMap.put("fontColor", hongbaoInfoFontColor);
|
| | | order.setHongBaoInfo(hongBaoMap);
|
| | | }
|
| | | } |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<CommonOrder> listBySourceTypeAndOrderId(int sourceType, String orderId) {
|
| | | |
| | | |
| | | |
| | |
|
| | | return null;
|
| | | } |
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public CommonOrder addTaoBaoOrder(TaoBaoOrder taoBaoOrder, Long uid) throws CommonOrderException {
|
| | | CommonOrder commonOrder = commonOrderMapper.selectByOrderNoAndOrderTypeAndOrderBy(taoBaoOrder.getOrderId(),
|
| | | Constant.SOURCE_TYPE_TAOBAO, taoBaoOrder.getOrderBy());
|
| | | if (commonOrder == null)// 新增
|
| | | {
|
| | | commonOrder = TaoBaoOrderUtil.convert(taoBaoOrder);
|
| | | CommonOrderGoods goods = new CommonOrderGoods();
|
| | | goods.setGoodsId(taoBaoOrder.getAuctionId() + "");
|
| | | goods.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | // 商品是否已经插入
|
| | | List<CommonOrderGoods> commonGoodsList = commonOrderGoodsMapper
|
| | | .listByGoodsIdAndGoodsType(goods.getGoodsId(), goods.getGoodsType());
|
| | | if (commonGoodsList.size() <= 0)// 不存在就插入商品
|
| | | {
|
| | | TaoBaoGoodsBrief taoBaoGoods = null;
|
| | | try {
|
| | | taoBaoGoods = TaoKeApiUtil.getSimpleGoodsInfo(taoBaoOrder.getAuctionId());
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if (taoBaoGoods != null) {
|
| | | goods = CommonOrderGoodsFactory.create(taoBaoGoods);
|
| | | }
|
| | | goods.setCreateTime(new Date());
|
| | | goods.setUpdateTime(new Date());
|
| | | commonOrderGoodsMapper.insertSelective(goods);
|
| | | } else
|
| | | goods.setId(commonGoodsList.get(commonGoodsList.size() - 1).getId());
|
| | | commonOrder.setCommonOrderGoods(goods);
|
| | | commonOrder.setUserInfo(new UserInfo(uid));
|
| | | commonOrder.setCreateTime(new Date());
|
| | | commonOrderMapper.insertSelective(commonOrder);
|
| | | return commonOrder;
|
| | | } else {// 修改
|
| | | // 已经结算或者已经失效的订单不处理
|
| | | if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_SX)
|
| | | return commonOrder;
|
| | | CommonOrder newCommonOrder = TaoBaoOrderUtil.convert(taoBaoOrder);
|
| | | CommonOrder updateCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | updateCommonOrder.seteIncome(newCommonOrder.geteIncome());
|
| | | updateCommonOrder.setEstimate(newCommonOrder.getEstimate());
|
| | | updateCommonOrder.setPayment(newCommonOrder.getPayment());
|
| | | updateCommonOrder.setSettlement(newCommonOrder.getSettlement());
|
| | | updateCommonOrder.setSettleTime(newCommonOrder.getSettleTime());
|
| | | updateCommonOrder.setState(newCommonOrder.getState());
|
| | | updateCommonOrder.setUpdateTime(new Date());
|
| | | commonOrderMapper.updateByPrimaryKeySelective(updateCommonOrder);
|
| | | return commonOrderMapper.selectByPrimaryKey(updateCommonOrder.getId());
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.order;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | |
|
| | |
|
| | | @Service
|
| | | public class HongBaoOrderServiceImpl implements HongBaoOrderService {
|
| | | |
| | |
|
| | | @Resource
|
| | | private HongBaoOrderMapper hongBaoOrderMapper;
|
| | |
|
| | |
|
| | | @Override
|
| | | public int insert(HongBaoOrder record) {
|
| | |
| | | return hongBaoOrderMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<HongBaoOrder> listFanLiOrder(Long uid, int page, int pageSize) {
|
| | | return hongBaoOrderMapper.listFanLiOrder(uid, (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countFanLiOrder(Long uid) {
|
| | | Long count = hongBaoOrderMapper.countFanLiOrder(uid);
|
| | | return count == null ? 0 : count;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Propagation;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.AccountDetailsMapper;
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.AccountDetails;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBao;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.MoneyRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.bus.user.OrderItem;
|
| | | 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.taobao.PidOrder;
|
| | | import com.yeshi.fanli.entity.taobao.PidUser;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | |
| | | import com.yeshi.fanli.exception.OrderItemException;
|
| | | import com.yeshi.fanli.exception.TaoBaoWeiQuanException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.hongbao.AccountDetailsHongBaoMapService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.LostOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderItemServcie;
|
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService;
|
| | |
| | | // 分离出返利订单与分享赚订单
|
| | | Iterator<String> its = orders.keySet().iterator();
|
| | | Map<String, List<TaoBaoOrder>> fanliOrderMap = new HashMap<>();
|
| | | Map<String, List<PidOrder>> shareOrderMap = new HashMap<>();
|
| | | Map<String, List<PidOrder>> sharePidOrderMap = new HashMap<>();
|
| | | Map<String, List<TaoBaoOrder>> shareOrderMap = new HashMap<>();
|
| | | while (its.hasNext()) {
|
| | | String orderId = its.next();
|
| | | if (orders.get(orderId) != null && orders.get(orderId).size() > 0) {
|
| | |
| | | list.get(0).getSourceMediaId(), list.get(0).getAdPositionId());
|
| | | PidUser pidUser = pidUserMapper.selectByPid(pid);
|
| | | if (pidUser != null && pidUser.getType() == PidUser.TYPE_SHARE_GOODS) {// 商品分享订单
|
| | | List<PidOrder> pidOrderList = new ArrayList<>();
|
| | | for (TaoBaoOrder order : list) {
|
| | | pidOrderList.add(TaoBaoOrderUtil.convertToPidOrder(order));
|
| | | }
|
| | | shareOrderMap.put(orderId, pidOrderList);
|
| | | // List<PidOrder> pidOrderList = new ArrayList<>();
|
| | | // for (TaoBaoOrder order : list) {
|
| | | // pidOrderList.add(TaoBaoOrderUtil.convertToPidOrder(order));
|
| | | // }
|
| | | // sharePidOrderMap.put(orderId, pidOrderList);
|
| | | shareOrderMap.put(orderId, list);
|
| | | } else {// 普通返利订单
|
| | | fanliOrderMap.put(orderId, list);
|
| | | }
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void processShopingFanliOrder(Map<String, List<TaoBaoOrder>> orders) {
|
| | | // 查询在Order中是否存在该订单号
|
| | | Iterator<String> its = orders.keySet().iterator();
|
| | | String tempOrderId = "";
|
| | | while (its.hasNext()) {
|
| | | try {
|
| | | String orderId = its.next();
|
| | | tempOrderId = orderId;
|
| | | // 处理红包与子红包
|
| | | // if (isRedisLockOrder(orderId))
|
| | | // continue;
|
| | | // redisLockOrder(orderId);
|
| | | processShopingFanliOrder(orderId, orders.get(orderId));
|
| | | processShopingFanliOrderNew(orderId, orders.get(orderId));
|
| | | // redisUnlockOrder(orderId);
|
| | | // 出错了就不处理该订单了,需要定期检查
|
| | |
|
| | |
| | | } catch (OrderItemException e2) {
|
| | | e2.printStackTrace();
|
| | | } catch (Exception e) {
|
| | |
|
| | | e.printStackTrace();
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, null, tempOrderId);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void processShareGoodsOrder(Map<String, List<PidOrder>> orders) {
|
| | | pidOrderService.addPidOrderFromTaoBao(orders);
|
| | | public void processShareGoodsOrder(Map<String, List<TaoBaoOrder>> orders) {
|
| | | // pidOrderService.addPidOrderFromTaoBao(orders);
|
| | | if (orders != null) {
|
| | | Iterator<String> its = orders.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String orderId = its.next();
|
| | | processShareGoodsOrderNew(orderId, orders.get(orderId));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | // 插入新版资金明细
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createFanLi(hb.getUserInfo().getId(),
|
| | | hb.getOrderId(), 1,hb.getId(), hb.getMoney());
|
| | | hb.getOrderId(), 1, hb.getId(), hb.getMoney());
|
| | | userMoneyDetail.setId(accountDetails.getId());
|
| | | userMoneyDetailMapper.insert(userMoneyDetail);
|
| | | } catch (UserMoneyDetailException e1) {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 处理一级二级分享赚(属于邀请赚类型)
|
| | | */
|
| | |
| | | drawBackOrders.add(hb.getOrderId());
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | // 邀请赚到账
|
| | | if (invitemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | userInfoMapper.addHongBaoByUid(uid, invitemoney);
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | /**
|
| | | * 分享赚到账
|
| | | */
|
| | |
| | |
|
| | | }
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void processShopingFanliOrderNew(String orderId, List<TaoBaoOrder> orderList)
|
| | | throws HongBaoException, OrderItemException {
|
| | | 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());
|
| | |
|
| | | Order oldOrder = orderMapper.selectOrderByOrderId(orderId);
|
| | | // 原来不存在订单
|
| | | Long uid = null;
|
| | | if (oldOrder == null) {
|
| | | PidUser pidUser = pidUserMapper.selectByPid(pid);
|
| | | if (pidUser != null) {
|
| | | uid = pidUser.getUid();
|
| | |
|
| | | // 插入到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();
|
| | |
|
| | | }
|
| | | // 尚未找到和PID对应的用户
|
| | | if (uid == null)
|
| | | return;
|
| | |
|
| | | // 计算订单总额度
|
| | | Order updateOrder = new Order();
|
| | | updateOrder.setId(oldOrder.getId());
|
| | | BigDecimal money = new BigDecimal(0);
|
| | | for (TaoBaoOrder o : orderList) {
|
| | | if (o.getOrderState().equalsIgnoreCase("订单结算"))
|
| | | money = money.add(o.getSettlement());
|
| | | else {
|
| | | money = money.add(o.getPayment());
|
| | | }
|
| | | }
|
| | | updateOrder.setMoney(money);
|
| | | String thirdState = null;
|
| | | for (TaoBaoOrder o : orderList)
|
| | | if (!o.getOrderState().equalsIgnoreCase("订单失效")) {
|
| | | thirdState = o.getOrderState();
|
| | | break;
|
| | | }
|
| | | updateOrder.setThirdState(thirdState);
|
| | | updateOrder.setThirdCreateTime(
|
| | | new Date(TimeUtil.convertToTimeTemp(orderList.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss")));
|
| | | orderMapper.updateByPrimaryKeySelective(updateOrder);
|
| | |
|
| | | // 用第一个子订单锁定用户
|
| | | for (TaoBaoOrder taoBaoOrder : orderList) {
|
| | | try {
|
| | | CommonOrder commonOrder = commonOrderService.addTaoBaoOrder(taoBaoOrder, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrder, HongBaoV2.TYPE_ZIGOU);
|
| | | } catch (CommonOrderException e) {
|
| | | e.printStackTrace();
|
| | | } catch (HongBaoException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @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 = pidUserMapper.selectByPid(pid);
|
| | | if (pidUser != null)
|
| | | uid = pidUser.getUid();
|
| | |
|
| | | // 尚未找到和PID对应的用户
|
| | | if (uid == null)
|
| | | return;
|
| | |
|
| | | // 用第一个子订单锁定用户
|
| | | for (TaoBaoOrder taoBaoOrder : orderList) {
|
| | | try {
|
| | | CommonOrder commonOrder = commonOrderService.addTaoBaoOrder(taoBaoOrder, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrder, HongBaoV2.TYPE_SHARE_GOODS);
|
| | | } catch (CommonOrderException e) {
|
| | | e.printStackTrace();
|
| | | } catch (HongBaoException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | * @return
|
| | | */
|
| | | public BigDecimal getShareRate(long time);
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 获取返利订单返利比例
|
| | | *
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getFanLiRate() ;
|
| | | public BigDecimal getFanLiRate();
|
| | |
|
| | | /**
|
| | | * 获取分享订单返利比例
|
| | |
| | | */
|
| | | public BigDecimal getShareRate();
|
| | |
|
| | | /**
|
| | | * 获取第一级的邀请赚比例
|
| | | * |
| | | * @return
|
| | | */
|
| | | public BigDecimal getFirstInviteRate(int urank);
|
| | |
|
| | | /**
|
| | | * 获取第一级的邀请赚比例
|
| | | * |
| | | * @param time
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getFirstInviteRate(int urank, long time);
|
| | |
|
| | | /**
|
| | | * 获取第二级的邀请赚比例
|
| | | * |
| | | * @return
|
| | | */
|
| | | public BigDecimal getSecondInviteRate(int urank);
|
| | |
|
| | | /**
|
| | | * 获取第二级的邀请赚比例
|
| | | * |
| | | * @param time
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getSecondInviteRate(int urank, long time);
|
| | |
|
| | | /**
|
| | | * 获取第一级的分享赚比例
|
| | | * |
| | | * @return
|
| | | */
|
| | | public BigDecimal getFirstShareRate(int urank);
|
| | |
|
| | | /**
|
| | | * 获取第一级的分享赚比例
|
| | | * |
| | | * @param time
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getFirstShareRate(int urank, long time);
|
| | |
|
| | | /**
|
| | | * 获取第二级的分享赚比例
|
| | | * |
| | | * @return
|
| | | */
|
| | | public BigDecimal getSecondShareRate(int urank);
|
| | |
|
| | | /**
|
| | | * 获取第二级的分享赚比例
|
| | | * |
| | | * @param time
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getSecondShareRate(int urank, long time);
|
| | |
|
| | | }
|
| | |
| | | import java.util.Map;
|
| | |
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderVO;
|
| | |
|
| | |
| | | */
|
| | | public List<CommonOrder> listBySourceTypeAndOrderId(int sourceType, String orderId);
|
| | |
|
| | | /**
|
| | | * 缓存普通订单
|
| | | * |
| | | * @param taoBaoOrder
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public CommonOrder addTaoBaoOrder(TaoBaoOrder taoBaoOrder, Long uid) throws CommonOrderException;
|
| | | |
| | | |
| | | |
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.order;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | |
|
| | | public interface HongBaoOrderService {
|
| | |
| | | public int insertSelective(HongBaoOrder record);
|
| | |
|
| | | public int updateByPrimaryKey(HongBaoOrder record);
|
| | | |
| | |
|
| | | public int updateByPrimaryKeySelective(HongBaoOrder record);
|
| | | |
| | |
|
| | | public int deleteByPrimaryKey(Long id);
|
| | | |
| | |
|
| | | public HongBaoOrder selectByPrimaryKey(Long id);
|
| | |
|
| | | /**
|
| | | * 老版本的用户返利订单列表
|
| | | * |
| | | * @param uid
|
| | | * @param page
|
| | | * @param pageSize
|
| | | * @return
|
| | | */
|
| | |
|
| | | public List<HongBaoOrder> listFanLiOrder(Long uid, int page, int pageSize);
|
| | |
|
| | | /**
|
| | | * 老版本用户返利订单数量
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public long countFanLiOrder(Long uid);
|
| | | }
|
| | |
| | | /**
|
| | | * 处理分享商品订单
|
| | | */
|
| | | public void processShareGoodsOrder(Map<String, List<PidOrder>> orders);
|
| | | public void processShareGoodsOrder(Map<String, List<TaoBaoOrder>> orders);
|
| | | |
| | | |
| | | |
| | | |
| | | public void processShopingFanliOrderNew(String orderId, List<TaoBaoOrder> orderList)
|
| | | throws HongBaoException, OrderItemException;
|
| | |
|
| | | /**
|
| | | * 处理分享商品订单
|
| | | */
|
| | | public void processShareGoodsOrderNew(String orderId, List<TaoBaoOrder> orderList);
|
| | |
|
| | | |
| | |
|
| | | /**
|
| | | * 处理返利
|
| | |
| | | public class Constant {
|
| | | public static boolean IS_TASK = false;
|
| | | // 外网环境
|
| | | public static boolean IS_OUTNET = true;
|
| | | public static boolean IS_OUTNET = false;
|
| | |
|
| | | public static boolean IS_TEST = false;
|
| | | public static boolean IS_TEST = true;
|
| | |
|
| | | public static int PAGE_SIZE = 20;
|
| | | public static int[] TASK_TYPE = { 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008// 微信任务类型编号
|
| | |
| | | private TaoBaoShopService taoBaoShopService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService; |
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
New file |
| | |
| | | package com.yeshi.fanli.util.factory;
|
| | |
|
| | | import com.yeshi.fanli.entity.order.CommonOrderGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
|
| | | public class CommonOrderGoodsFactory {
|
| | |
|
| | | public static CommonOrderGoods create(TaoBaoGoodsBrief goods) {
|
| | | if (goods == null)
|
| | | return null;
|
| | | CommonOrderGoods orderGoods = new CommonOrderGoods();
|
| | | orderGoods.setGoodsId(goods.getAuctionId() + "");
|
| | | orderGoods.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | orderGoods.setPicture(goods.getPictUrl());
|
| | | orderGoods.setPrice(goods.getZkPrice());
|
| | | orderGoods.setShopId(goods.getSellerId());
|
| | | orderGoods.setShopName(goods.getShopTitle());
|
| | | if (goods.getUserType() == 0)
|
| | | orderGoods.setShopType(CommonOrderGoods.TYPE_TAOBAO);
|
| | | else
|
| | | orderGoods.setShopType(CommonOrderGoods.TYPE_TMALL);
|
| | | orderGoods.setTitle(goods.getTitle());
|
| | | return orderGoods;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | } else if ("订单结算".equalsIgnoreCase(taoBaoOrder.getOrderState())) {
|
| | | state = CommonOrder.STATE_JS;
|
| | | }
|
| | |
|
| | | commonOrder.setOrderBy(taoBaoOrder.getOrderBy());
|
| | | commonOrder.setState(state);
|
| | | commonOrder.setThirdCreateTime(
|
| | | new Date(TimeUtil.convertToTimeTemp(taoBaoOrder.getCreateTime(), "yyyy-MM-dd HH:mm:ss")));
|
| | |
| | | for (int i = 0; i < array.size(); i++) {
|
| | | String itemStr = array.optString(i).replace("<img", "<a").replace("</img>", "<a>");
|
| | | html += itemStr;
|
| | | }
|
| | | } |
| | | Document doc = Jsoup.parse(html);
|
| | | Elements items = doc.getElementsByTag("a");
|
| | | for (int i = 0; i < items.size(); i++) {
|
| | |
| | | img.setPicture(item.ownText().trim());
|
| | | else
|
| | | img.setPicture("http:" + item.ownText().trim());
|
| | | imgList.add(img);
|
| | | }
|
| | | if (img != null && img.getPicture() != null && img.getPicture().endsWith(".jpg"))
|
| | | imgList.add(img);
|
| | | } |
| | | |
| | | }
|
| | | }
|
| | |
|
| | |
| | | druid.driverClassName=com.mysql.jdbc.Driver
|
| | | #本地测试
|
| | | #druid.url=jdbc:mysql://192.168.1.122:3306/ec_quan
|
| | | #druid.username=root
|
| | | #druid.password=hexiaohui
|
| | | druid.url=jdbc:mysql://192.168.1.122:3306/ec_quan
|
| | | druid.username=root
|
| | | druid.password=hexiaohui
|
| | |
|
| | |
|
| | | #druid.url=jdbc:mysql://192.168.1.253:3306/ec_quan
|
| | |
| | |
|
| | |
|
| | | #外网正式
|
| | | druid.url=jdbc:mysql://172.16.16.17:3306/ec_quan
|
| | | druid.username=root
|
| | | druid.password=Yeshi2016@
|
| | | #druid.url=jdbc:mysql://172.16.16.17:3306/ec_quan
|
| | | #druid.username=root
|
| | | #druid.password=Yeshi2016@
|
| | |
|
| | | #外网本地测试
|
| | | #druid.url=jdbc:mysql://gz-cdb-r13d0yi9.sql.tencentcdb.com:62929/ec_quan
|
| | | #druid.url=jdbc:mysql://gz-cdb-r13d0yi9.sql.tencentcdb.com:62929/ec_quan_test
|
| | | #druid.username=root
|
| | | #druid.password=Yeshi2016@
|
| | |
|