唐古拉優選拼團系統設計模式和唐古拉優選拼團系統核心代碼介紹


拼團玩法又被視為社交電商下的社交玩法,由於其自帶營銷屬性,因此較好的解決了產品推廣和流量的問題,最常見的玩法就是團長在社群里面發布相關拼團活動,隨手成百上千個社群內的弱關系用戶便自由組團,使得參團人數呈裂變式增長。拼團玩法高中獎率會提高用戶的積極性,沒中獎也可以獲得購物優惠券,整體而言,中獎用戶獲得更大的收益,沒中獎用戶也不會產生過多的厭惡感,並且也能通過優惠券刺激用戶消費。這是李鐵牛這么多年做產品開發的一些心得體驗,關於電商系統研發和產品模式的玩法,歡迎和李鐵牛探討交流,微信號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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM