Girlday.php 1.39 KB
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/3/4
 * Time: 12:18
 */
namespace Cuxiao;
use LibModels\Wap\Cuxiao\ActivityData;

class GirldayModel
{
    /**
     * 获取领券活动结果
     *
     * @param int $uid 用户id
     * @param int $actId 活动id
     * @return array
     */
    public static function getGirldayCoupon($uid, $actId)
    {
        $result = array('code' => 201);

        do {
            if (empty($uid) || empty($actId)) {
                break;
            }

            $result = ActivityData::getCouponAll($uid, $actId);
            if (!$result) {
                $result = array('code' => 201);
                break;
            }

            if (intval($result['code']) === 200) {
                self::sendMessage($uid, '【优惠券】您有4张春潮新势力优惠券', '尊敬的客户:恭喜您成功获得4张春潮新势力优惠券 !您可以在个人中心查看优惠券详情。');
            }
        } while (false);

        return $result;
    }

    /**
     * 发送站内信
     *
     * @param int $uid 用户ID
     * @param string $title 站内信标题
     * @param string $content 站内信内容
     */
    private static function sendMessage($uid, $title, $content)
    {
        try {
            ActivityData::message($uid, $title, $content);
        } catch (Exception $e) {
            // do nothing
        }
    }
}