/** * 送礼物 * @Author Wayne[qiaobin@zhiyicx.com] * @DateTime 2016-10-12T21:55:46+0800 * @return [type] [description] */ public function haddleGift() { if (!$this->is_ZhiboService()) { return array('status' => 0, 'msg' => '授权错误'); } $data = $_REQUEST; //获取订单 $order = $data['order']; if (!$order) { $this->error = '订单不存在'; return false; } /* 接收订单详细信息 **/ $gift = ['num' => $data['num'], 'to_usid' => $data['to_usid'], 'usid' => $data['usid'], 'type' => $data['type'], 'order' => $data['order'], 'description' => $data['description'], 'ctime' => $data['ctime'], 'order_type' => $data['order_type']]; $map['usid'] = array('IN', array('"' . $gift['usid'] . '"', '"' . $gift['to_usid'] . '"')); $uids = M('live_user_info')->where($map)->getField('usid,uid'); $gift['to_uid'] = $uids[$gift['to_usid']]; $gift['uid'] = $uids[$gift['usid']]; $credit_mod = new CreditUser(); $user_data = $credit_mod->where('uid', $gift['uid'])->select('score')->first(); if ($user_data['score'] < $gift['num']) { return array('status' => 0, 'message' => '金币数量不足'); } $live_gift_log = M('live_gift_log'); $res = M('live_gift_log')->add($gift); if (!$res) { //赠送记录 echo json_encode(['status' => 0, 'message' => '记录添加失败']); exit; } else { //用户积分增加以及减少 $creditMod = model('Credit'); $creditMod->setUserCredit($gift['uid'], array('des' => '赠送礼物', 'score' => -$gift['num'], 'name' => '', 'alias' => '赠送礼物', 'type' => 6, 'cid' => 0), 1, array('score' => -$gift['num'], 'order' => $gift['order'])); $creditMod->setUserCredit($gift['to_uid'], array('des' => '收到礼物', 'score' => $gift['num'], 'name' => '收到礼物', 'alias' => '收到礼物', 'type' => 6, 'cid' => 0), 1, array('score' => $gift['num'], 'order' => $gift['order'])); echo json_encode(['status' => 1, 'data' => ['is_sync' => 1]]); exit; } die; }
/** * 查询账单接口 * @Author Wayne[qiaobin@zhiyicx.com] * @DateTime 2016-10-27T14:58:32+0800 */ public function ZB_Trade_Get_Status() { $trade_order = $this->jiemi(t($_POST['trade_order'])); $trade_order = t($_POST['trade_order']); if (!$trade_order) { return array('code' => '00404', 'message' => '订单号丢失了'); } $map['trade_order'] = $trade_order; $order = M('order_logs')->where($map)->getField('save_status'); $user_data = model('UserData')->getUserData($this->mid); $user_gold = CreditUser::where('uid', $this->mid)->select('zan_remain as zan_count', 'score as gold')->first(); $data['zan_count'] = $user_gold['zan_count']; $data['gold'] = $user_gold['gold']; // if($order != 1) // { // return $order == 0 ? array('code' => '00505', 'message' =>'交易处理中') : array('code'=>'00506', 'message' => '交易被驳回'); // } return array('code' => '00000', 'data' => array_merge($data, array('follow_count' => $user_data['following_count'] ? $user_data['following_count'] : 0, 'fans_count' => $user_data['follower_count'] ? $user_data['follower_count'] : 0))); }