Ver código fonte

优化了新用户领取新人红包接口,将循环调用的功能去除了

liu 2 meses atrás
pai
commit
95cb2aa23f

+ 3 - 0
src/main/java/com/sqx/modules/app/dao/UserDao.java

@@ -7,6 +7,7 @@ import com.sqx.common.utils.Result;
 import com.sqx.modules.app.entity.UserEntity;
 import com.sqx.modules.app.entity.queryRiderVo;
 import com.sqx.modules.app.entity.queryRidersVo;
+import com.sqx.modules.errand.entity.ErrandRedPacket;
 import com.sqx.modules.errand.vo.queryOrderInfoVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -79,4 +80,6 @@ public interface UserDao extends BaseMapper<UserEntity> {
     int updateUserShopClientIdIsNull(String clientid);
 
     List<UserEntity> selectRiderUserByOnLineFlag(String distance, String lng, String lat);
+
+    void batchAddRedPacket(@Param("redPacketList") List<ErrandRedPacket> redPacketList);
 }

+ 8 - 0
src/main/java/com/sqx/modules/errand/entity/ErrandRedPacket.java

@@ -67,4 +67,12 @@ public class ErrandRedPacket {
     @TableField(value = "delete_flag")
     private String deleteFlag;
 
+    /**
+     * 红包领取时间
+     */
+    @ApiModelProperty(value = "红包领取时间")
+    @TableField(value = "create_time")
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
+    private Date createTime;
+
 }

+ 16 - 1
src/main/java/com/sqx/modules/errand/service/impl/TbIndentServiceImpl.java

@@ -2225,8 +2225,23 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
             redPacket.setRedPacketType("0");
             redPacket.setRedPacketTitle("跑腿专用红包");
             redPacket.setMinimumAmount(new BigDecimal(0));
+            ArrayList<ErrandRedPacket> errandRedPackets = new ArrayList<>();
             for (int i = 0; i < integer; i++) {
-                userDao.addRedPacket(userId, redPacket.getRedPacketType(), redPacket.getMinimumAmount(), redPacketAmount, redPacket.getRedPacketTitle(), expirationTime, createTime);
+                ErrandRedPacket errandRedPacket = new ErrandRedPacket();
+                errandRedPacket.setUserId(userId);
+                errandRedPacket.setRedPacketType(redPacket.getRedPacketType());
+                errandRedPacket.setMinimumAmount(redPacket.getMinimumAmount());
+                errandRedPacket.setRedPacketAmount(redPacketAmount);
+                errandRedPacket.setRedPacketTitle(redPacket.getRedPacketTitle());
+                errandRedPacket.setExpirationTime(addDate);
+                errandRedPacket.setDeleteFlag("0");
+                errandRedPacket.setCreateTime(date);
+                errandRedPackets.add(errandRedPacket);
+ //               userDao.addRedPacket(userId, redPacket.getRedPacketType(), redPacket.getMinimumAmount(), redPacketAmount, redPacket.getRedPacketTitle(), expirationTime, createTime);
+            }
+            // 批量插入
+            if (errandRedPackets.size()>0) {
+                userDao.batchAddRedPacket(errandRedPackets);
             }
             //修改用户为非新用户
             int i = userDao.updateOldUser(userId);

+ 81 - 31
src/main/resources/mapper/app/UserDao.xml

@@ -45,10 +45,18 @@
 
 
     <select id="queryRider" resultType="com.sqx.modules.app.entity.queryRiderVo">
-        select u.user_id,u.clientid,u.open_id,u.rider_open_id,u.user_name,u.phone,u.cash_deposit,u.check_certification,r.station_name
+        select u.user_id,
+               u.clientid,
+               u.open_id,
+               u.rider_open_id,
+               u.user_name,
+               u.phone,
+               u.cash_deposit,
+               u.check_certification,
+               r.station_name
         from tb_user u
-        left join rider_station r on r.id = u.rider_station_id
-        where  u.user_id = #{userId}
+                 left join rider_station r on r.id = u.rider_station_id
+        where u.user_id = #{userId}
     </select>
 
     <select id="queryRiders" resultType="com.sqx.modules.app.entity.queryRidersVo">
@@ -64,9 +72,10 @@
 
 
     <select id="queryInviterCount" resultType="int">
-        select count(*) from tb_user
-        where inviter_code=#{inviterCode}
-     </select>
+        select count(*)
+        from tb_user
+        where inviter_code = #{inviterCode}
+    </select>
     <select id="queryUserCount" resultType="int">
         select count(*)from tb_user where 1=1
         <if test="type==1">
@@ -326,8 +335,8 @@
     </select>
 
     <update id="updateCashDeposit">
-        update tb_user set
-        cash_deposit = cash_deposit+#{cashDeposit}
+        update tb_user
+        set cash_deposit = cash_deposit + #{cashDeposit}
         where user_id = #{userId}
     </update>
 
@@ -353,9 +362,17 @@
     </select>
 
     <select id="findUserMessage" resultType="com.sqx.modules.app.entity.UserEntity">
-        select tu.*, um.birthday as birthday, um.height as height, um.weight as weight, um.occupation as occupation, um.individual_resume as individualResume,
-        um.picture_list as pictureList, um.sex as umSex
-         from tb_user tu left join user_message um on tu.user_id = um.user_id where tu.user_id = #{userId}
+        select tu.*,
+               um.birthday          as birthday,
+               um.height            as height,
+               um.weight            as weight,
+               um.occupation        as occupation,
+               um.individual_resume as individualResume,
+               um.picture_list      as pictureList,
+               um.sex               as umSex
+        from tb_user tu
+                 left join user_message um on tu.user_id = um.user_id
+        where tu.user_id = #{userId}
     </select>
 
     <select id="selectUser" resultType="com.sqx.modules.app.entity.UserEntity">
@@ -371,8 +388,8 @@
     <select id="selectUserById" resultType="com.sqx.modules.app.entity.UserEntity">
         select tu.*, um.money as money, ui.integral_num as integralNum
         from tb_user tu
-        left join user_money um on tu.user_id = um.user_id
-        left join user_integral ui on tu.user_id = ui.user_id
+                 left join user_money um on tu.user_id = um.user_id
+                 left join user_integral ui on tu.user_id = ui.user_id
         where tu.user_id = #{userId}
     </select>
 
@@ -382,54 +399,87 @@
     </insert>
 
     <update id="certification">
-        update tb_user set user_name = #{userName}, audit_time = #{format},  identity_card_number = #{identityCardNumber}, identity_card_front = #{identityCardFront},
-        identity_card_verso = #{identityCardVerso}, self_identity_card = #{selfIdentityCard}, check_certification = "0", cash_deposit=#{cashDeposit}, check_number=#{checkNumber} where user_id = #{userId}
+        update tb_user
+        set user_name            = #{userName},
+            audit_time           = #{format},
+            identity_card_number = #{identityCardNumber},
+            identity_card_front  = #{identityCardFront},
+            identity_card_verso  = #{identityCardVerso},
+            self_identity_card   = #{selfIdentityCard},
+            check_certification  = "0",
+            cash_deposit=#{cashDeposit},
+            check_number=#{checkNumber}
+        where user_id = #{userId}
     </update>
 
     <insert id="userFeedback">
         insert into sys_feedback (feedback_type, user_id, user_email, feedback_score, feedback_message, feedback_time)
-        values
-        (#{feedbackType}, #{userId}, #{userEmail}, #{feedbackScore}, #{feedbackMessage}, #{format})
+        values (#{feedbackType}, #{userId}, #{userEmail}, #{feedbackScore}, #{feedbackMessage}, #{format})
     </insert>
 
     <insert id="addRedPacket">
-        insert into errand_user_red_packet (user_id, red_packet_type, minimum_amount, red_packet_amount, red_packet_title, expiration_time, delete_flag, create_time)
-        values (#{userId}, #{redPacketType}, #{minimumAmount}, #{redPacketAmount}, #{redPacketTitle}, #{expirationTime}, "0", #{createTime})
+        insert into errand_user_red_packet (user_id, red_packet_type, minimum_amount, red_packet_amount,
+                                            red_packet_title, expiration_time, delete_flag, create_time)
+        values (#{userId}, #{redPacketType}, #{minimumAmount}, #{redPacketAmount}, #{redPacketTitle}, #{expirationTime},
+                "0", #{createTime})
     </insert>
 
     <update id="updateOldUser">
-        update tb_user set new_user_flag = "2" where user_id = #{userId}
+        update tb_user
+        set new_user_flag = "2"
+        where user_id = #{userId}
     </update>
 
     <select id="selectUserMessage" resultType="com.sqx.modules.app.entity.UserEntity">
-        select tu.*, gs.status as shopStatus from tb_user tu left join sys_user_shop sus on tu.admin_user_id = sus.user_id
-        left join goods_shop gs on sus.shop_id = gs.shop_id
+        select tu.*, gs.status as shopStatus
+        from tb_user tu
+                 left join sys_user_shop sus on tu.admin_user_id = sus.user_id
+                 left join goods_shop gs on sus.shop_id = gs.shop_id
         where tu.user_id = #{userId}
     </select>
 
     <select id="selectVipOverdue" resultType="com.sqx.modules.app.entity.UserEntity">
-        select * from tb_user where is_vip = 1 and vip_expiration_time &lt; #{date}
+        select *
+        from tb_user
+        where is_vip = 1
+          and vip_expiration_time &lt; #{date}
     </select>
 
     <update id="updateUserClientIdIsNull">
-        update tb_user set clientid='' where clientid=#{clientid}
+        update tb_user
+        set clientid=''
+        where clientid = #{clientid}
     </update>
 
     <update id="updateUserRiderClientIdIsNull">
-        update tb_user set rider_clientid='' where rider_clientid=#{clientid}
+        update tb_user
+        set rider_clientid=''
+        where rider_clientid = #{clientid}
     </update>
 
     <update id="updateUserShopClientIdIsNull">
-        update tb_user set shop_client_id='' where shop_client_id=#{clientid}
+        update tb_user
+        set shop_client_id=''
+        where shop_client_id = #{clientid}
     </update>
 
     <select id="selectRiderUserByOnLineFlag" resultType="com.sqx.modules.app.entity.UserEntity">
-        select * from (select (st_distance (point (r.lng, r.lat),point(#{lng},#{lat}) ) *111195) as distance,t.*
-                       from rider_location r
-                                left join tb_user t on t.user_id=r.user_id
-                       where  t.on_line_flag=1
-                      ) a where distance&lt;=#{distance}
+        select *
+        from (select (st_distance(point(r.lng, r.lat), point(#{lng}, #{lat})) * 111195) as distance, t.*
+              from rider_location r
+                       left join tb_user t on t.user_id = r.user_id
+              where t.on_line_flag = 1) a
+        where distance &lt;= #{distance}
     </select>
 
+    <insert id="batchAddRedPacket" parameterType="java.util.List">
+        insert into errand_user_red_packet (user_id, red_packet_type, minimum_amount, red_packet_amount,
+        red_packet_title, expiration_time, delete_flag, create_time)
+        values
+        <foreach collection="redPacketList" item="item" index="index" separator=",">
+            (#{item.userId}, #{item.redPacketType}, #{item.minimumAmount}, #{item.redPacketAmount},
+            #{item.redPacketTitle}, #{item.expirationTime}, '0', #{item.createTime})
+        </foreach>
+    </insert>
 
 </mapper>