123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <?php
- namespace huo\controller\posts;
- use huo\controller\common\Base;
- use huo\controller\member\MemCache;
- use huo\controller\request\Channel;
- use huo\controller\request\Device;
- use huo\controller\request\Game;
- use huo\controller\request\Mem;
- use huo\controller\shop\ItgOrder;
- use huo\logic\posts\PostsLogic;
- use huo\logic\posts\ShareActLogic;
- use huo\model\posts\PostsModel;
- use huo\model\posts\ShareLogModel;
- use huolib\constant\MemItgConst;
- use huolib\constant\ShareConst;
- use huolib\status\CommonStatus;
- class ShareAct extends Base {
-
- public function callback(Game $game_rq, Channel $channel, Device $device, Mem $member, $_share_data = []) {
-
- $_share_type = get_val($_share_data, 'share_type');
- $_to_target = get_val($_share_data, 'to_target');
- if (empty($_share_type) || empty($_to_target)) {
- return $this->huoError(CommonStatus::INVALID_PARAMS);
- }
-
- $_target_types_key = array_keys(ShareConst::getTargetTypeMsg(null, true));
- if (!in_array($_to_target, $_target_types_key)) {
- return $this->huoError(CommonStatus::INVALID_PARAMS);
- }
- if (ShareConst::SHARE_TYPE_POSTS == $_share_type) {
- $_act_id = get_val($_share_data, 'share_id');
- if (empty($_act_id)) {
- return $this->huoError(CommonStatus::INVALID_PARAMS);
- }
- $post = (new PostsLogic())->getDetail($_act_id);
- if (empty($post)) {
- return $this->huoError(CommonStatus::INVALID_PARAMS);
- }
-
- $_share_data['title'] = $post['title'];
- $_share_data['content'] = $post['excerpt'];
- $_share_data['url'] = $post['url'];
- $_share_data['table_name'] = (new PostsModel())->getName();
- $_share_data['object_id'] = $_act_id;
- $_share_act_logic = new ShareActLogic();
-
- $_share_log = (new ShareLogModel())->getTodayShareLog($member->getMemId(), $_to_target);
- if (empty($_share_log)) {
-
- $_itg_order = ItgOrder::ins();
- $_mc_class = MemCache::ins();
- $_me_data = $_mc_class->getInfoById($member->getMemId());
-
- $count = $_itg_order->getDayMobileDrawCount($_me_data['mobile'], $_act_id);
- if ($count <= MemItgConst::MAX_LOTTERY_DRAW_COUNT) {
- $_reward_cnt = ShareConst::DEFAULT_SHARE_INCR_COUNT;
- $_rs = $_share_act_logic->incrLotteryCnt($member->getMemId(), $_act_id, $_reward_cnt);
- if (false == $_rs) {
- return $this->huoError(
- CommonStatus::INNER_ERROR, CommonStatus::getMsg(CommonStatus::INNER_ERROR)
- );
- }
- }
-
- $_rs = $_share_act_logic->insertShareLog($game_rq, $channel, $device, $member, $_share_data);
- if (false == $_rs) {
- return $this->huoError(CommonStatus::INNER_ERROR, CommonStatus::getMsg(CommonStatus::INNER_ERROR));
- }
- }
- }
- return $this->huoSuccess(CommonStatus::NO_ERROR, CommonStatus::getMsg(CommonStatus::NO_ERROR));
- }
-
- public function resetLotteryCnt($mem_id, $act_id) {
- $_share_act_logic = new ShareActLogic();
- $_free_cnt = ShareConst::DEFAULT_LOTTERY_FREE_COUNT;
-
- $_itg_order = ItgOrder::ins();
- $_mc_class = MemCache::ins();
- $_m_data = $_mc_class->getInfoById($mem_id);
-
- $count = $_itg_order->getDayMobileDrawCount($_m_data['mobile'], $act_id);
- if ($count > MemItgConst::MAX_LOTTERY_DRAW_COUNT) {
- $_free_cnt = 0;
- }
- $_rs = $_share_act_logic->resetLotteryCnt($mem_id, $act_id, $_free_cnt);
- if (true !== $_rs) {
- return $this->huoError(CommonStatus::INVALID_PARAMS);
- }
- return $this->huoSuccess(CommonStatus::NO_ERROR);
- }
- }
|