快付生态系统积分交易核心源码段
快付生态系统重要单位是积分,积分的产出也是通过系统的任务模型来产生的。会员如果要获取更多的积分或者开启的任务需要的积分不够,那么就需要向平台的会员购买积分
会员之间积分互转涉及到自助模式,自助交易模式类似OTC挂单交易,这种挂单交易模式有一个好处是,平台作为托底担保方,会员之前转移的积分都经过平台的监管,这样也更高效便捷。
积分交易也是系统运营的核心功能,在此和大家一起分享下快付生态app积分交易核心源码端,系统开发交流李铁牛15889726201
系统积分交易购买流程:
1.卖家设积分挂单到系统公海
2.买家选择要购买积分单
3.卖家付款并上传付款凭证
4.卖家确认收款,并确认积分转出
以下是积分交易核心代码段
public function creditOrderDetailAction() { $post = input('post.'); $data = [ 'code' => 0, 'msg' => '操作失败', 'data' => [] ]; do{ //参数不正确 if( !$post['id'] OR !in_array($post['type'],['confirm_expend','refund','appeal','confirm_income'])) { break; } //比对用户id和卖家id和对应的类型是否一致 $order_info = Order::find($post['id'])->toArray(); if( ( $order_info['status'] == 1 && !in_array($post['type'],['confirm_expend','refund','appeal'])) OR ( $order_info['status'] == 2 && !in_array($post['type'],['appeal','confirm_income'])) OR ($order_info['status'] == 3 && !in_array($post['type'],['refund','confirm_income'])) OR $order_info['status'] == 4 OR $order_info['status'] == 5 ) { $data['msg'] = '订单状态错误'; break; } $post_info = Jfyz::find($order_info['post_id'])->toArray(); if( ( in_array($post['type'],['appeal','confirm_income']) && $order_info['uid'] != self::$userInfo['id'] ) OR ( in_array($post['type'],['refund','confirm_expend']) && $post_info['uid'] != self::$userInfo['id'] ) ) { break; } if( $post['type'] == 'confirm_expend' && !$post['thumb']) { $data['msg'] = '请上传转款凭证'; break; } if( in_array($post['type'],['appeal','refund']) && !$post['note']) { $data['msg'] = '请填写原因'; } $status = [ 'confirm_expend' => 2, 'appeal' => 3, 'refund' => 4, 'confirm_income' => 5 ]; Jfyz::startTrans(); $mobile = ''; $json_data = ''; if( in_array($post['type'],['confirm_expend','refund'])) { $member_info = Member::field('id,openid,credit1,mobile')->where('id',$order_info['uid'])->find()->toArray(); $mobile = $member_info['mobile']; $json_data = $post['type'] == 'confirm_expend' ? '{money:"'.bcsub(bcmul($order_info['credit'],0.97,2),2,2).'"}' : '{credit:"'.$order_info['credit'].'"}'; } try{ //修改订单状态; $order_update = ['status'=>$status[$post['type']],'edit_time'=>time()]; if($post['type'] == 'confirm_expend') $order_update['thumb'] = $post['thumb']; if($post['type'] == 'refund' OR $post['type'] == 'appeal') $order_update['note'] = $post['note']; Order::where('id',$post['id'])->update($order_update); //如果是驳回,就得退回积分给用户,同时增加卖家可收入积分,减少卖家锁定的积分。 if( $post['type'] == 'refund') { //增加日志: $member_info['credit1'] = Member::getUserCredit($order_info['uid'],'credit1'); MemberCreditRecord::creditLog($member_info,$order_info['credit'],'credit1','积分兑换被驳回,退回'.$order_info['credit'].'积分','10'); //减少用户积分 Member::creditAction( $order_info['uid'],$order_info['credit'],0,'credit1'); //返回可收积分的值 Jfyz::where('id',$order_info['post_id'])->exp('lock_credit','lock_credit - '.$order_info['credit'])->exp('allow_credit','allow_credit + '.$order_info['credit'])->update(); //如果状态为已过期,则恢复状态 if(Jfyz::where('id',$order_info['post_id'])->where('status',4)->value('allow_credit') > 1000 ) Jfyz::where('id',$order_info['post_id'])->update(['status'=>3]); } //如果是确认收款,就得释放卖家锁定的积分,增加卖家的可提现积分。 if( $post['type'] == 'confirm_income' ) Jfyz::where('id',$order_info['post_id'])->exp('lock_credit','lock_credit - '.$order_info['credit'])->exp('income_credit','income_credit + '.$order_info['credit'])->update(); Jfyz::commit(); $data['code'] = 1; $data['msg'] = '操作成功!'; //发送短信 if( $mobile ) @Sms::main($mobile,$json_data,($post['type'] == 'refund' ? 'refund' : 'exchange') ); } catch ( \Exception $e) { var_dump($e->getMessage()); var_dump($e->getLine()); var_dump($e->getFile()); Jfyz::rollback(); } }while(0); return json($data); }
微信号:tieniu6636
分类:
软件产品设计
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类