拼团玩法又被视为社交电商下的社交玩法,由于其自带营销属性,因此较好的解决了产品推广和流量的问题,最常见的玩法就是团长在社群里面发布相关拼团活动,随手成百上千个社群内的弱关系用户便自由组团,使得参团人数呈裂变式增长。
唐古拉优选拼团系统核心代码如下
//唐古拉优选拼团系统开发,李铁牛 15889726201
public static function completeGroup()
{
$fpff = fopen("./fflock.txt", "w+");
$author = '唐古拉优选拼团系统开发,李铁牛 15889726201';
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('支付订单不存在!唐古拉优选拼团系统开发,李铁牛 15889726201');
if ($order['refund_status'] == 2) return self::setErrorInfo('订单已退款!');
if ($order['refund_status'] == 1) return self::setErrorInfo('正在申请退款中!');
if ($order['status'] == 1) return self::setErrorInfo('订单当前无法退款!唐古拉优选拼团系统开发,李铁牛 15889726201');
$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;
}
![唐古拉优选拼团系统](https://img-blog.csdnimg.cn/20210304171107593.jpeg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3ZlbnVzMTUw,size_16,color_FFFFFF,t_70)
对消费者来说,对商品性价比的追求是永远不会停息。人们对于日常用品以及绝大部分的零售商品,都想要以优惠的价格来获取更优质的商品,在这个基础上,拼团就成为了更优更快的有效渠道。对于商家而言,除了能够短时间拓展大量的真实成交客源,传统的团购活动需要借助平台的帮助与支付昂贵的广告费,现在,商家可以通过优嘉励平台,自主在企业的微信公众号投放拼团活动,也再无需与传统的团购平台分享利润。
对于消费者而言,在唐古拉优选拼团能够以超低折扣的机会体验,不仅是一种生活的方式更是生活的乐趣,这也正是用户乐衷于将商品及商家信息与朋友分享讨论的原因所在。