join('ls_plug as p on p.id=pm.plug_id AND p.type=1') ->where($map) ->field('p.*') ->select(); $this->assign('plug', $plug); $this->display(); } //公用领取红包成功页面 public function reward_success() { $money = I('get.money'); if (empty($money)) { $this->tipsMsg(0, '您访问的页面不存在'); } else { $this->assign('money', $money); $this->display(); } } //公众号红包页面 public function reward() { $this->display(); } public function openReward() { $user = session('userinfo'); if (IS_POST) { if (empty($user)) { $result['status'] = 0; $result['msg'] = '访问错误'; $this->ajaxReturn($result); } $item = array( 'vid' => $user['id'], 'merchant_id' => $user['merchantid'], 'store_id' => $user['storeid'], 'grade_integral' => $user['grade_integral'], ); $result = A('Api/RewardDealApi')->rewardDeal($item, 1); $this->ajaxReturn($result); } } //线下支付成功拆红包页面 public function reward_pay() { $order_id = I('get.bill_order_id');//bill_order表id if (empty($order_id)) { $this->tipsMsg(0, '你访问的页面不存在'); } $BillModel = D('RetailBillOrder'); $bMap = array( 'id' => $order_id, 'type' => 2, 'order_type' => 1, 'pay_state' => 1, ); $Order = $BillModel->getFind($bMap); if (empty($Order)) { $this->tipsMsg(0, '你访问的页面不存在'); } else { $RecordModel = D('RetailRewardRecord'); $map = array( 'bill_id' => $order_id, ); $recordList = $RecordModel->getFind($map); if ($recordList) { $this->tipsMsg(0, '红包已被领取'); } $this->assign('order_id', $order_id); $this->display(); } } //线下线上支付成功拆红包接口 public function openPayReward() { $user = session('userinfo'); $order_id = I('post.order_id'); $BillModel = D('RetailBillOrder'); $map = array( 'id' => $order_id, 'type' => 2, 'order_type' => 1, 'pay_state' => 1, ); $bill = $BillModel->getFind($map); if (empty($order_id) || empty($bill)) { $result['status'] = 0; $result['msg'] = '访问错误'; $this->ajaxReturn($result); } $RecordModel = D('RetailRewardRecord'); $recordList = $RecordModel->getFind(array('bill_id' => $order_id)); if (!empty($recordList)) { $result['status'] = 0; $result['msg'] = '红包已经被领取了'; $this->ajaxReturn($result); } $item = array( 'vid' => $user['id'], 'merchant_id' => $user['merchantid'], 'store_id' => $bill['store_id'], 'need_money' => $bill['all_money'], 'grade_integral' => $user['grade_integral'], 'order_id' => $order_id, ); $result = A('Api/RewardDealApi')->rewardDeal($item, 2); $this->ajaxReturn($result); } /* * 我的红包列表 */ public function rewardList() { $user = session('userinfo'); $page = I('post.page'); $limit = I('post.limit'); if (!empty($limit) && !empty($page)) { $pages = "$page,$limit"; } else { $pages = " "; } if (empty($user)) { $result['status'] = 0; $result['msg'] = '访问错误'; $this->ajaxReturn($result); } $RetailRewardRecordModel = D('RetailRewardRecord'); $filed = array( $RetailRewardRecordModel::MONEY, $RetailRewardRecordModel::ADD_TIME, $RetailRewardRecordModel::REWARD_ID, $RetailRewardRecordModel::STATUS ); $RetailRewardRecord = $RetailRewardRecordModel->getSelect(array($RetailRewardRecordModel::VID => $user['id'], $RetailRewardRecordModel::MERCHANT_ID => $user['merchantid']), $filed, 'id desc', $pages); foreach ($RetailRewardRecord as &$val) { $RetailRewardModel = D('RetailReward'); $tpye = $RetailRewardModel->getFindField(array($RetailRewardModel::ID => $val[$RetailRewardRecordModel::REWARD_ID]), $RetailRewardModel::TYPE); $val['addtimes'] = date('Y.m.d H:i:s'); if ($tpye == 1) { $val['remark'] = '公众号红包'; } elseif ($tpye == 2) { $val['remark'] = '线下消费红包'; } elseif ($tpye == 3) { $val['remark'] = '商城登录红包'; } elseif ($tpye == 4) { $val['remark'] = '线上消费红包'; } } $this->ajaxReturn($RetailRewardRecord); } }