唐古拉优选拼团系统设计模式和唐古拉优选拼团系统核心代码介绍
作者:互联网
拼团玩法又被视为社交电商下的社交玩法,由于其自带营销属性,因此较好的解决了产品推广和流量的问题,最常见的玩法就是团长在社群里面发布相关拼团活动,随手成百上千个社群内的弱关系用户便自由组团,使得参团人数呈裂变式增长。拼团玩法高中奖率会提高用户的积极性,没中奖也可以获得购物优惠券,整体而言,中奖用户获得更大的收益,没中奖用户也不会产生过多的厌恶感,并且也能通过优惠券刺激用户消费。这是李铁牛这么多年做产品开发的一些心得体验,关于电商系统研发和产品模式的玩法,欢迎和李铁牛探讨交流,微信号15889726201
其中核心玩法:
这是整个拼团玩法里面,用户最多,覆盖面最广的玩法。这种玩法通常都是选择截止高、噱头大、话题及传播性强的产品作为拼团商品。
主要参与流程如下:
1.用户参与拼团并成团
2.在成团后,系统会进行抽奖
3.被抽中的用户才可以获得拼团商品
4.拼团失败自动退款
5.拼团成功的未中奖用户自动退款同时可获得补偿优惠券
唐古拉优选拼团系统核心代码如下
//唐古拉优选拼团系统开发,李铁牛 15889726201 public static function completeGroup() { $fpff = fopen("./fflock.txt", "w+");if(flock($fpff,LOCK_EX)){ $pinkListEndWin = self::pinkListEndWin(); if (!$pinkListEndWin) return true; $pinkListEndWin = $pinkListEndWin->toArray(); foreach ($pinkListEndWin as $key => $value) { $countPeople = (int)bcadd(StorePink::where('k_id', $value['id'])->count(), 1, 0); //如果拼团人数未达到 if ($countPeople < $value['people']){ continue; } $pinkLists = StorePink::where('k_id', $value['id'])->column('id', 'id'); $pinkLists[] = $value['id']; $pinkLists = array_values($pinkLists); //随机出中奖者 $win_id_index = array_rand($pinkLists,1); //$win_id_index = 12; $win_id = $pinkLists[$win_id_index]; if( !$win_id ) continue; try{ self::beginTrans(); //拼团系统开发,李铁牛 15889726201 StorePink::where('id','IN',$pinkLists)->update(['is_win'=>1]); /** ::todo 中奖处理开始 */ //拼团中奖 unset($pinkLists[$win_id_index]); $win_info = StorePink::get($win_id); if( ! $win_info ) continue; $win_info = $win_info->toArray(); //发放中奖的推荐奖励 self::sendRecommendReward($win_info['uid'],$win_info['price'],$win_info['cid'],0); //修改订单状态 $update_info = [ 'status' => 2, //订单状态, ]; StoreOrder::update($update_info,['order_id'=>$win_info['order_id']]); /** ::todo 未中奖处理开始 */ self::failRefundPink($pinkLists);//申请退款 self::commitTrans(); } catch (\Exception $e) { self::rollbackTrans(); var_dump($e->getMessage()); continue; } } flock($fpff,LOCK_UN); } fclose($fpff); } /** * 获取拼团数据 * @return \think\Collection * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function pinkListEndWin() { $model = StorePink::field('id,people');//开团编号 $model = $model->where('stop_time', '<=', time());//小于当前时间 $model = $model->where('status', 2);//进行中的拼团 $model = $model->where('k_id', 0);//团长 $model = $model->where('is_win', 0);//是否开奖 $model = $model->where('is_refund', 0);//未退款 return $model->select(); } /** * 发放推广奖励 * @param $uid * @param $price * @param $cid * @param int $type * @return mixed * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function sendRecommendReward($uid,$price,$cid,$type=0) { $user_info = User::getUserInfo($uid); if( $user_info['spread_uid'] > 0 ) { $combination_info = self::find($cid); if( $combination_info ) $combination_info = $combination_info->toArray(); $spreadUserInfo = User::getUserInfo($user_info['spread_uid']); if( $spreadUserInfo ) { $reward_rate = $type ? $combination_info['indirect_recommend_tate'] : $combination_info['direct_recommend_tate']; $reward_num = bcmul($price,$reward_rate/100,2); if($reward_num){ $note = $type ? '间推奖励' : '直推奖励'; User::bcInc($spreadUserInfo['uid'], 'now_money', $reward_num, 'uid'); UserBill::income($note, $spreadUserInfo['uid'], 'now_money', 'product_profits', $reward_num, $combination_info['product_id'], bcadd($spreadUserInfo['now_money'], $reward_num, 2), $note . floatval($price) . '元'); if( $spreadUserInfo['spread_uid'] > 0 && $type == 0 ) return self::sendRecommendReward($spreadUserInfo['uid'],$price,$cid,1); } } } } /** * 拼团未中 申请退款 * @param $pinkList * @return bool * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException */ public static function failRefundPink($pinkList) { $refundPinkList = StorePink::where('id', 'IN', $pinkList)->column('order_id,uid,price,id,cid,people,pid', 'id'); if (!count($refundPinkList)) return true; foreach ($refundPinkList as $key => $item) { $fail_rebate_rate = self::where('id', $item['cid'])->value('fail_rebate_rate'); if( $fail_rebate_rate < 0 ) return false; $refund_price = bcdiv($item['price']*$fail_rebate_rate/100,$item['people']-1,2); $user_info = User::getUserInfo($item['uid']); //拼团未中奖返点 User::bcInc($item['uid'], 'now_money', $refund_price, 'uid'); UserBill::income('拼团未中奖', $item['uid'], 'now_money', 'product_profits', $refund_price, $item['pid'], bcadd($user_info['now_money'], $refund_price, 2), '拼团未中奖' . floatval($refund_price) . '元'); User::bcInc($item['uid'], 'now_money', $item['price'], 'uid'); UserBill::income('拼团未中奖退款', $item['uid'], 'now_money', 'product_profits', $item['price'], $item['pid'], bcadd($item['price'],bcadd($user_info['now_money'], $refund_price, 2),2), '拼团未中奖退款' . floatval($refund_price) . '元'); //退款 self::ptorderApplyRefund($item['order_id'], $item['uid'], '拼团未中奖');//申请退款 //修改拼团订单状态 StorePink::where('id', $item['id'])->update(['status' => 3]); } } /** * 退款处理 * @param $uni * @param $uid * @param string $refundReasonWap * @param string $refundReasonWapExplain * @param array $refundReasonWapImg * @return bool * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException */ public static function ptorderApplyRefund($uni, $uid, $refundReasonWap = '', $refundReasonWapExplain = '', $refundReasonWapImg = []) { $order = StoreOrder::getUserOrderDetail($uid, $uni); if (!$order) return self::setErrorInfo('支付订单不存在!唐古拉优选拼团'); if ($order['refund_status'] == 2) return self::setErrorInfo('订单已退款!'); if ($order['refund_status'] == 1) return self::setErrorInfo('正在申请退款中!'); if ($order['status'] == 1) return self::setErrorInfo('订单当前无法退款!'); $res1 = false !== StoreOrderStatus::status($order['id'], 'apply_refund', '用户申请退款,原因:' . $refundReasonWap); $res2 = false !== StoreOrder::edit(['status'=>'-1','refund_status' => 2, 'refund_reason_time' => time(), 'refund_reason_wap' => $refundReasonWap, 'refund_reason_wap_explain' => $refundReasonWapExplain, 'refund_reason_wap_img' => json_encode($refundReasonWapImg)], $order['id'], 'id'); $author = '唐古拉优选拼团系统开发,李铁牛 15889726201'; return true; }
对消费者来说,对商品性价比的追求是永远不会停息。人们对于日常用品以及绝大部分的零售商品,都想要以优惠的价格来获取更优质的商品,在这个基础上,拼团就成为了更优更快的有效渠道。对于商家而言,除了能够短时间拓展大量的真实成交客源,传统的团购活动需要借助平台的帮助与支付昂贵的广告费,现在,商家可以通过优嘉励平台,自主在企业的微信公众号投放拼团活动,也再无需与传统的团购平台分享利润。
对于消费者而言,在通过拼团能够以超低折扣的机会体验,不仅是一种生活的方式更是生活的乐趣,这也正是用户乐衷于将商品及商家信息与朋友分享讨论的原因所在。
这是李铁牛做做电商程序开发的一点心得体验,关于电商系统研发和产品模式的玩法,欢迎和李铁牛探讨交流,微信号15889726201
posted on 2021-03-04 17:52 海姆达尔 阅读(339) 评论(0) 编辑 收藏
标签:info,优选,uid,price,item,拼团,唐古拉,id 来源: https://blog.51cto.com/u_13168809/2834717