moonsflyer 2 maanden geleden
bovenliggende
commit
d164de7c2a

+ 0 - 131
app/admin/controller/Express.php

@@ -1,131 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\admin\controller;
-
-use app\admin\validate\ExpressValidate;
-use app\common\basics\AdminBase;
-use app\common\server\ConfigServer;
-use app\common\logic\ExpressLogic;
-use app\common\server\JsonServer;
-use think\db;
-use think\exception\ValidateException;
-
-class Express extends AdminBase
-{
-    /**
-     * lists
-     * @return mixed
-     * @throws \think\exception\DbException
-     * @throws db\exception\DataNotFoundException
-     * @throws db\exception\ModelNotFoundException
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            return JsonServer::error('', ExpressLogic::lists($get));
-        }
-    }
-
-    /**
-     * 添加
-     * @return mixed
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['del'] = 0;
-            try {
-                validate(ExpressValidate::class)->scene('add')->check($post);
-                $result = ExpressLogic::addExpress($post);
-                if ($result) {
-                    return JsonServer::success('添加成功');
-                }
-                return JsonServer::error($result);
-            } catch (ValidateException $e) {
-                return JsonServer::error($e->getMessage());
-            }
-        }
-        return view();
-    }
-
-    /**
-     * 编辑
-     * @param $id
-     * @return mixed
-     */
-    public function edit($id)
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['del'] = 0;
-            try {
-                validate(ExpressValidate::class)->scene('edit')->check($post);
-                $result = ExpressLogic::editExpress($post);
-                if ($result) {
-                    return JsonServer::success('修改成功');
-                }
-                return JsonServer::error($result);
-            } catch (ValidateException $e) {
-                return JsonServer::error($e->getMessage());
-            }
-        }
-        return view('', [
-            'info' => ExpressLogic::info($id)
-        ]);
-    }
-
-
-    /**
-     * 删除
-     * @param $delData
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public function del($delData)
-    {
-        if ($this->request->isAjax()) {
-            $result = ExpressLogic::delExpress($delData);
-            if ($result) {
-                return JsonServer::success('删除成功');
-            }
-            return JsonServer::error('删除失败');
-        }
-    }
-
-    //查询配置
-    public function setExpress()
-    {
-        $post = $this->request->post();
-        if ($post) {
-            ConfigServer::set('express', 'way', $post['way']);
-
-            ConfigServer::set('kd100', 'appkey', $post['kd100_appkey']);
-            ConfigServer::set('kd100', 'appsecret', $post['kd100_customer']);
-
-            ConfigServer::set('kdniao', 'appkey', $post['kdniao_appkey']);
-            ConfigServer::set('kdniao', 'appsecret', $post['kdniao_ebussinessid']);
-            ConfigServer::set('kdniao', 'type', $post['kdniao_type']);
-        }
-        return JsonServer::success('操作成功');
-    }
-}

+ 0 - 105
app/admin/controller/Recharge.php

@@ -1,105 +0,0 @@
-<?php
-namespace app\admin\controller;
-
-use app\common\basics\AdminBase;
-use app\admin\logic\RechargeLogic;
-use app\common\server\JsonServer;
-use app\admin\validate\RechargeTemplateValidate;
-use think\exception\ValidateException;
-
-class Recharge extends AdminBase
-{
-    public function lists(){
-        if($this->request->isAjax()){
-            $get = $this->request->get();
-            if($get['type'] == 1){ // 充值方案
-                $list = RechargeLogic::templatelists($get['type']);
-            }else{ // 充值配置
-                $list = RechargeLogic::getRechargeConfig();
-            }
-            return JsonServer::success('', $list);
-
-        }
-        return view();
-    }
-
-    public function add(){
-
-        if ($this->request->isAjax()){
-            $post = $this->request->post();
-            try{
-                validate(RechargeTemplateValidate::class)->check($post);
-            }catch(ValidateException $e) {
-                return JsonServer::error($e->getError());
-            }
-            $result = RechargeLogic::add($post);
-            if ($result === true){
-                return JsonServer::success('新增成功');
-            }
-            return JsonServer::error(RechargeLogic::getError());
-
-        }
-        return view();
-    }
-
-    public function changeFields(){
-        $table = 'recharge_template';
-
-        $pk_name = 'id';
-        $pk_value = $this->request->get('id');
-
-        $field = $this->request->get('field');
-        $field_value = $this->request->get('value');
-        $result = RechargeLogic::changeTableValue($table,$pk_name,$pk_value,$field,$field_value);
-        if($result){
-            return JsonServer::success('修改成功');
-        }
-        return JsonServer::error('修改失败');
-    }
-
-    public function edit($id){
-        if ($this->request->isAjax()){
-            $post = $this->request->post();
-            try{
-                validate(RechargeTemplateValidate::class)->check($post);
-            }catch(ValidateException $e) {
-                return JsonServer::error($e->getError());
-            }
-            $result = RechargeLogic::edit($post);
-            if ($result === true){
-                return JsonServer::success('编辑成功');
-            }
-            return JsonServer::error('编辑失败');
-        }
-
-        $info = RechargeLogic::getRechargeTemplate($id);
-        return view('', [
-            'info' => $info
-        ]);
-    }
-
-    public function del($id)
-    {
-        if ($this->request->isAjax()) {
-            $result = RechargeLogic::del($id);
-            if ($result) {
-                return JsonServer::success('删除成功');
-            }
-            return JsonServer::error('删除失败');
-        }
-    }
-
-    public function setRecharge(){
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            if($post['give_growth'] < 0) {
-                return JsonServer::error('赠送成长值不能小于0');
-            }
-            if($post['min_money'] < 0) {
-                return JsonServer::error('最低充值金额不能小于0');
-            }
-            RechargeLogic::setRecharge($post);
-            return JsonServer::success('设置成功');
-        }
-    }
-}

+ 0 - 172
app/admin/controller/Seckill.php

@@ -1,172 +0,0 @@
-<?php
-declare (strict_types = 1);
-
-namespace app\admin\controller;
-
-use app\admin\logic\SeckillLogic;
-use app\common\server\JsonServer;
-use think\Request;
-use think\Controller;
-use app\common\basics\AdminBase;
-
-class Seckill extends AdminBase
-{
-    public function lists(){
-        $seckill_time = SeckillLogic::getTimeAll();
-        return view('', [
-            'seckill' => $seckill_time
-        ]);
-    }
-    /**
-     * note 秒杀商品
-     * create_time 2020/11/13 16:01
-     */
-    public function goodsLists(){
-        if($this->request->isAjax()){
-            $get = $this->request->get();
-            $list = SeckillLogic::goodsList($get);
-            return JsonServer::success('',$list,0);
-        }
-    }
-
-    /**
-     * note 秒杀时间
-     * create_time 2020/11/13 16:01
-     */
-    public function timeLists(){
-        if($this->request->isAjax()){
-            $get= $this->request->get();
-            $list = SeckillLogic::timeList($get);
-            return JsonServer::success('',$list,0);
-        }
-    }
-    /**
-     * note 添加秒杀时间段
-     * create_time 2020/11/13 16:01
-     */
-    public function addTime(){
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            $result = $this->validate($post, 'app\admin\validate\SeckillTime');
-            if($result === true){
-                SeckillLogic::addTime($post);
-                $this->_success('新增成功','');
-            }
-            $this->_error($result,'');
-
-
-        }
-        return $this->fetch();
-    }
-
-    /**
-     * note 编辑秒杀时间段
-     * create_time 2020/11/13 16:02
-     */
-    public function editTime($id){
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            $result = $this->validate($post, 'app\admin\validate\SeckillTime');
-            if($result === true){
-                SeckillLogic::editTime($post);
-                $this->_success('编辑成功','');
-            }
-            $this->_error($result,'');
-        }
-        $this->assign('detail',SeckillLogic::getTime($id));
-        return $this->fetch();
-    }
-
-    /**
-     * note 删除秒杀时间段
-     * create_time 2020/11/13 16:02
-     */
-    public function delTime(){
-        if($this->request->isAjax()){
-            $id = $this->request->post('id');
-            $result = SeckillLogic::delTime($id);
-
-            if($result == true){
-                $this->_success('删除成功','');
-            }
-            return $this->_error('删除失败','');
-
-
-        }
-    }
-    /**
-     * note 添加秒杀商品
-     * create_time 2020/11/13 16:02
-     */
-    public function addGoods(){
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            $post['item'] = form_to_linear($post);
-            $result = $this->validate($post,'app\admin\validate\SeckillGoods.add');
-            if($result === true){
-                $result = SeckillLogic::addGoods($post);
-                if($result){
-                    $this->_success('新增成功','');
-                }
-                $result = '新增失败';
-            }
-            $this->_error($result);
-
-        }
-        $seckill_time = SeckillLogic::getTimeAll();
-        foreach ($seckill_time as $k=>$v){
-//            $seckill_time[$k]["time"]
-        }
-        return view('', [
-            'seckill' =>$seckill_time
-        ]);
-//        $this->assign('seckill',$seckill_time);
-//        return $this->fetch();
-    }
-    /**
-     * note 编辑秒杀商品
-     * create_time 2020/11/13 16:02
-     */
-    public function editGoods(){
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            $post['item'] = form_to_linear($post);
-            $result = $this->validate($post,'app\admin\validate\SeckillGoods.edit');
-            if($result === true){
-                $result = SeckillLogic::editGoods($post);
-                if($result){
-                    $this->_success('编辑成功','');
-                }
-                $result = '编辑失败';
-            }
-            $this->_error($result);
-
-
-        }
-        $id = $this->request->get('id');
-        $seckill_id = $this->request->get('seckill_id');
-
-        $detail = SeckillLogic::getSeckillGoods($id,$seckill_id);
-        $seckill_time = SeckillLogic::getTimeAll();
-        $this->assign('seckill',$seckill_time);
-        $this->assign('detail',$detail);
-        return $this->fetch();
-    }
-
-    /**
-     * note 删除秒杀商品
-     * create_time 2020/11/13 16:05
-     */
-    public function delGoods(){
-        if($this->request->isAjax()){
-            $id = $this->request->post('id');
-            $seckill_id = $this->request->post('seckill_id');
-            $result = SeckillLogic::delGoods($id,$seckill_id);
-
-            if($result == true){
-                $this->_success('删除成功','');
-            }
-            return $this->_error('删除失败','');
-        }
-    }
-}

+ 0 - 139
app/admin/logic/RechargeLogic.php

@@ -1,139 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\admin\logic;
-
-use app\common\basics\Logic;
-use app\common\model\RechargeTemplate;
-use think\facade\Db;
-use app\common\server\ConfigServer;
-
-class RechargeLogic extends Logic
-{
-    public static function templatelists(){
-        $list = RechargeTemplate::where(['del'=>0])->order(['sort' => 'desc'])->select()->toArray();
-        foreach ($list as &$item){
-            $item['money'] && $item['money'] = '¥'.$item['money'];
-            $item['give_money'] && $item['give_money'] = '¥'.$item['give_money'];
-        }
-        return $list;
-    }
-
-    public static function getRechargeConfig(){
-        $config =  [
-            'open_racharge'  => ConfigServer::get('recharge','open_racharge',0),
-            'give_growth'    => ConfigServer::get('recharge', 'give_growth', 0),
-            'min_money'      => ConfigServer::get('recharge', 'min_money', 0),
-        ];
-        return [$config];
-    }
-
-    public static function add($post){
-        try{
-            // 判断充值金额是否已存在
-            $recharge_template = RechargeTemplate::where([
-                'del' =>0,
-                'money' => $post['money']
-            ])->findOrEmpty();
-            if(!$recharge_template->isEmpty()) {
-                throw new \think\Exception('该充值金额的模板已存在');
-            }
-            $new = time();
-            $add_data = [
-                'money'         => $post['money'],
-                'give_money'    => $post['give_money'],
-                'sort'          => $post['sort'],
-                'is_recommend'  => $post['is_recommend'],
-                'create_time'   => $new,
-                'update_time'   => $new,
-            ];
-            RechargeTemplate::create($add_data);
-            return true;
-        }catch(\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    public static function changeTableValue($table,$pk_name,$pk_value,$field,$field_value){
-        //允许修改的字段
-        $allow_field = [
-            'is_show','sort','status','is_new','is_best','is_like','is_recommend'
-        ];
-        if(!in_array($field,$allow_field)){
-            return false;
-        }
-        if(is_array($pk_value)){
-            $where[] = [$pk_name,'in',$pk_value];
-        }else{
-            $where[] = [$pk_name,'=',$pk_value];
-        }
-
-        $data= [
-            $field          => $field_value,
-            'update_time'   => time(),
-        ];
-
-        return Db::name($table)->where($where)->update($data);
-    }
-
-
-    public static function getRechargeTemplate($id){
-        return Db::name('recharge_template')->where(['id'=>$id])->find();
-    }
-
-    public static function edit($post){
-        try{
-            // 判断充值金额是否已存在
-            $recharge_template = RechargeTemplate::where([
-                ['del', '=', 0],
-                ['money', '=', $post['money']],
-                ['id', '<>', $post['id']],
-            ])->findOrEmpty();
-            if(!$recharge_template->isEmpty()) {
-                throw new \think\Exception('该充值金额的模板已存在');
-            }
-            $new = time();
-            $update_data = [
-                'id'            => $post['id'],
-                'money'         => $post['money'],
-                'give_money'    => $post['give_money'],
-                'sort'          => $post['sort'],
-                'is_recommend'  => $post['is_recommend'],
-                'update_time'   => $new,
-            ];
-            RechargeTemplate::update($update_data);
-            return true;
-        }catch(\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    public static function del($id){
-        return Db::name('recharge_template')->where(['id'=>$id])->update(['update_time'=>time(),'del'=>1]);
-    }
-
-    public static function setRecharge($post){
-        ConfigServer::set('recharge','open_racharge',$post['open_racharge']);
-        ConfigServer::set('recharge','give_growth',$post['give_growth']);
-        ConfigServer::set('recharge','min_money',$post['min_money']);
-    }
-}

+ 0 - 35
app/admin/validate/RechargeTemplateValidate.php

@@ -1,35 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\admin\validate;
-use think\Validate;
-
-class RechargeTemplateValidate extends Validate{
-    protected $rule = [
-        'money'          => 'require|gt:0',
-        'give_money'     => 'egt:0',
-        'sort'         => 'integer|egt:0',
-    ];
-    protected $message = [
-        'money.require'     => '请输入充值金额',
-        'money.gt'          => '充值金额须为大于0',
-        'give_money.egt'     => '赠送金额须为大于0',
-        'sort.integer'    => '排序值须为整数',
-        'sort.egt'        => '排序值须大于或等于0',
-    ];
-}

+ 0 - 44
app/admin/view/recharge/add.html

@@ -1,44 +0,0 @@
-{layout name="layout2" /}
-<div class="layui-form" lay-filter="">
-    <div class="layui-tab">
-        <div class="layui-form-item layui-col-sm6  layui-col-md4">
-            <label class="layui-form-label"><font color="red">*</font>充值金额</label>
-            <div class="layui-input-block">
-                <input type="number" name="money" lay-verify="required" lay-verType="tips" placeholder="请输入充值金额" autocomplete="off" class="layui-input">
-            </div>
-        </div>
-        <div class="layui-form-item layui-col-sm6  layui-col-md4">
-            <label class="layui-form-label">赠送金额</label>
-            <div class="layui-input-block">
-                <input type="number" name="give_money" lay-verType="tips" placeholder="请输入赠送金额" autocomplete="off" class="layui-input">
-            </div>
-        </div>
-
-        <div class="layui-form-item layui-col-sm6  layui-col-md4">
-            <label class="layui-form-label">排序</label>
-            <div class="layui-input-block">
-                <input type="number"  name="sort" value="100"  placeholder="请输入排序" class="layui-input">
-            </div>
-        </div>
-
-        <div class="layui-form-item">
-            <label class="layui-form-label">推荐</label>
-            <div class="layui-input-inline">
-                <input type="radio" name="is_recommend" value="1" title="是" >
-                <input type="radio" name="is_recommend" value="0" title="否" checked>
-            </div>
-        </div>
-        <div class="layui-form-item layui-hide">
-            <input type="button" lay-submit lay-filter="add-recharge-submit" id="add-recharge-submit" value="确认">
-        </div>
-    </div>
-</div>
-<script>
-    layui.config({
-        version:"{$front_version}",
-        base: '/static/lib/' //静态资源所在路径
-    }).use(['form'], function(){
-        var $ = layui.$
-            ,form = layui.form
-    });
-</script>

+ 0 - 45
app/admin/view/recharge/edit.html

@@ -1,45 +0,0 @@
-{layout name="layout2" /}
-<div class="layui-form" lay-filter="">
-    <input type="hidden" name="id" value="{$info.id}">
-    <div class="layui-tab">
-        <div class="layui-form-item layui-col-sm6  layui-col-md4">
-            <label class="layui-form-label"><font color="red">*</font>充值金额</label>
-            <div class="layui-input-block">
-                <input type="number" name="money" value="{$info.money}" lay-verify="required" lay-verType="tips" placeholder="请输入充值金额" autocomplete="off" class="layui-input">
-            </div>
-        </div>
-        <div class="layui-form-item layui-col-sm6  layui-col-md4">
-            <label class="layui-form-label">赠送金额</label>
-            <div class="layui-input-block">
-                <input type="number" name="give_money" value="{$info.give_money}" lay-verType="tips" placeholder="请输入赠送金额" autocomplete="off" class="layui-input">
-            </div>
-        </div>
-
-        <div class="layui-form-item layui-col-sm6  layui-col-md4">
-            <label class="layui-form-label">排序</label>
-            <div class="layui-input-block">
-                <input type="number"  name="sort" value="{$info.sort}"  placeholder="请输入排序" class="layui-input">
-            </div>
-        </div>
-
-        <div class="layui-form-item">
-            <label class="layui-form-label">推荐</label>
-            <div class="layui-input-inline">
-                <input type="radio" name="is_recommend" value="1" title="是" {if condition="$info.is_recommend eq 1" } checked {/if} >
-                <input type="radio" name="is_recommend" value="0" title="否" {if condition="$info.is_recommend eq 0" } checked {/if} >
-            </div>
-        </div>
-        <div class="layui-form-item layui-hide">
-            <input type="button" lay-submit lay-filter="edit-recharge-submit" id="edit-recharge-submit" value="确认">
-        </div>
-    </div>
-</div>
-<script>
-    layui.config({
-        version:"{$front_version}",
-        base: '/static/lib/' //静态资源所在路径
-    }).use(['form'], function () {
-        var $ = layui.$
-            , form = layui.form
-    });
-</script>

+ 0 - 366
app/admin/view/recharge/lists.html

@@ -1,366 +0,0 @@
-{layout name="layout1" /}
-<style>
-    .layui-form-label{
-        width: 150px;
-    }
-</style>
-<div class="wrapper">
-    <div class="layui-card">
-        <div class="layui-card-body">
-            <div class="layui-collapse like-layui-collapse" lay-accordion="" style="border:1px dashed #c4c4c4">
-                <div class="layui-colla-item">
-                    <h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示</h2>
-                    <div class="layui-colla-content layui-show">
-                        <p>*设定充值方案后,会员可以选择推荐的充值方案充值。</p>
-                        <p>*充值设置允许关闭充值功能。</p>
-                        <p>*充值金额不能提现。</p>
-                    </div>
-                </div>
-            </div>
-        </div>
-        <div class="layui-tab layui-tab-card" lay-filter="tab-all">
-            <ul class="layui-tab-title">
-                <li data-type="1" class="layui-this">充值方案</li>
-                <li data-type="2" >充值设置</li>
-            </ul>
-            <div class="layui-tab-content">
-                <div class="layui-tab-item layui-show">
-                    <div class="layui-card">
-                        <div class="layui-card-body">
-                            <div style="padding-bottom: 10px;" class="add">
-                                <button class="layui-btn layui-btn-sm layuiadmin-btn-recharge {$view_theme_color}" data-type="add">新增充值方案</button>
-                            </div>
-                            <table id="recharge-lists" lay-filter="recharge-lists"></table>
-                            <script type="text/html" id="recharge-operation">
-                                <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="edit">编辑</a>
-                                <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
-                            </script>
-                            <script type="text/html" id="recommend">
-                                <input type="checkbox"  lay-filter="switch-status" data-id={{d.id}} data-field='is_recommend'   lay-skin="switch"
-                                       lay-text="是|否" {{#  if(d.is_recommend){ }} checked  {{#  } }} />
-                            </script>
-
-                        </div>
-                    </div>
-                </div>
-                <div class="layui-tab-item">
-
-                    <div class="layui-form" lay-filter="">
-                        <div class="layui-form-item">
-                            <label class="layui-form-label">充值功能:</label>
-                            <div class="layui-input-inline">
-                                <input type="radio" name="open_racharge" value="1" title="开启">
-                                <input type="radio" name="open_racharge" value="0" title="关闭">
-                            </div>
-                        </div>
-                        <div class="layui-form-item">
-                            <label class="layui-form-label"></label>
-                            <span style="color: #a3a3a3;font-size: 9px">开启或关闭充值功能,关闭后商城会隐藏充值功能入口</span>
-                        </div>
-                        <div class="layui-form-item">
-                            <label class="layui-form-label">充值赠送成长值:</label>
-                            <div class="layui-input-inline">
-                                <input type="number" name="give_growth" autocomplete="off" class="layui-input give_growth">
-                            </div>
-                        </div>
-                        <div class="layui-form-item">
-                            <label class="layui-form-label"></label>
-                            <span style="color: #a3a3a3;font-size: 9px">填写每充值1元赠送成长值,填写正整数</span>
-                        </div>
-                        <div class="layui-form-item">
-                            <label class="layui-form-label">最低充值金额:</label>
-                            <div class="layui-input-inline">
-                                <input type="number" name="min_money" autocomplete="off" class="layui-input min_money">
-                            </div>
-                        </div>
-                        <div class="layui-form-item">
-                            <label class="layui-form-label"></label>
-                            <span style="color: #a3a3a3;font-size: 9px">自定义充值最低充值金额要求,不填或填0表示没有限制</span>
-                        </div>
-                        <div class="layui-form-item">
-                            <div class="layui-input-block">
-                                <button class="layui-btn layui-btn-sm {$view_theme_color}" lay-submit lay-filter="set">确定</button>
-                            </div>
-                        </div>
-
-                    </div>
-
-                </div>
-            </div>
-
-
-        </div>
-    </div>
-</div>
-<style>
-    .layui-table-cell {
-        height: auto;
-    }
-</style>
-<script>
-    layui.config({
-        version:"{$front_version}",
-        base: '/static/lib/' //静态资源所在路径
-    }).use(['table','form'], function(){
-        var $ = layui.$
-            ,form = layui.form
-            ,table = layui.table
-            ,element = layui.element;
-
-        $('.layui-btn.layuiadmin-btn-recharge').on('click', function(){
-            var type = $(this).data('type');
-            active[type] ? active[type].call(this) : '';
-        });
-
-        //事件
-        var active = {
-            add: function(){
-                var index = layer.open({
-                    type: 2
-                    ,title: '新增充值方案'
-                    ,content: '{:url("recharge/add")}'
-                    ,area: ['60%', '60%']
-                    ,btn: ['保存', '取消']
-                    ,maxmin: true
-                    ,yes: function(index, layero){
-                        var iframeWindow = window['layui-layer-iframe'+ index]
-                            ,submitID = 'add-recharge-submit'
-                            ,submit = layero.find('iframe').contents().find('#'+ submitID);
-                        //监听提交
-                        iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
-                            var field = data.field;
-                            like.ajax({
-                                url:'{:url("recharge/add")}',
-                                data:field,
-                                type:"post",
-                                success:function(res)
-                                {
-                                    if(res.code == 1)
-                                    {
-                                        layui.layer.msg(res.msg, {
-                                            offset: '15px'
-                                            , icon: 1
-                                            , time: 1000
-                                        });
-                                        layer.close(index); //关闭弹层
-                                        table.reload('recharge-lists'); //数据刷新
-                                    }
-                                }
-                            });
-                        });
-
-                        submit.trigger('click');
-                    }
-                });
-            }
-        }
-
-        //获取列表
-        getList(1)
-        //切换列表
-        element.on('tab(tab-all)', function (data) {
-            var type = $(this).attr('data-type');
-            getList(type)
-        });
-        form.on('switch(switch-status)',function (obj) {
-            var id = obj.elem.attributes['data-id'].nodeValue
-            var fields = obj.elem.attributes['data-field'].nodeValue
-            var status = 0;
-            if(this.checked){
-                status = 1;
-            }
-
-            changeFields(id,fields,status);
-        })
-
-        //监听工具条
-        table.on('tool(recharge-lists)', function(obj){
-            var id = obj.data.id;
-            if(obj.event === 'edit'){
-                var id = obj.data.id;
-                layer.open({
-                    type: 2
-                    ,title: '修改充值方案'
-                    ,content: '{:url("recharge/edit")}?id='+id
-                    ,area: ['60%','60%']
-                    ,btn: ['确定', '取消']
-                    ,yes: function(index, layero){
-                        var iframeWindow = window['layui-layer-iframe'+ index]
-                            ,submitID = 'edit-recharge-submit'
-                            ,submit = layero.find('iframe').contents().find('#'+ submitID);
-                        //监听提交
-                        iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
-                            var field = data.field;
-                            like.ajax({
-                                url:'{:url("recharge/edit")}',
-                                data:field,
-                                type:"post",
-                                success:function(res)
-                                {
-                                    if(res.code == 1)
-                                    {
-                                        layui.layer.msg(res.msg, {
-                                            offset: '15px'
-                                            , icon: 1
-                                            , time: 1000
-                                        });
-                                        layer.close(index); //关闭弹层
-                                        table.reload('recharge-lists'); //数据刷新
-                                    }
-                                }
-                            });
-                        });
-
-                        submit.trigger('click');
-                    }
-                })
-            }
-            if(obj.event === 'del'){
-                var money = obj.data.money;
-                layer.confirm('确定删除充值金额:'+'<span style="color: red">'+money+'</span>', function(index){
-                    like.ajax({
-                        url:'{:url("recharge/del")}',
-                        data:{id:id},
-                        type:"post",
-                        success:function(res)
-                        {
-                            if(res.code == 1)
-                            {
-                                layui.layer.msg(res.msg, {
-                                    offset: '15px'
-                                    , icon: 1
-                                    , time: 1000
-                                });
-                                layer.close(index); //关闭弹层
-                                table.reload('recharge-lists'); //数据刷新
-                            }
-                        }
-                    });
-                    layer.close(index);
-
-
-                })
-
-            }
-            if(obj.event === 'tips'){
-                layer.tips('数字越大,越靠前', $(this), {tips: [1, '#FF5722'],time:1500});
-            }
-
-
-        });
-        //商品排序
-        table.on('edit(recharge-lists)', function (obj) {
-            var id = obj.data.id;
-            var fields = 'sort';
-            var field_value = obj.value;
-
-            if(isNaN(field_value)){
-                var old_value=$(this).prev().text();
-
-                layer.tips('请输入数字', $(this), {tips: [1, '#FF5722']});
-                $(this).val(old_value);
-
-                return false;
-            }
-
-            changeFields(id,fields,field_value);
-
-        });
-        form.on('submit(set)', function (data) {
-            like.ajax({
-                url: '{:url("recharge/setRecharge")}' //实际使用请改成服务端真实接口
-                , data: data.field
-                , type: 'post'
-                , success: function (res) {
-                    if (res.code == 1) {
-                        layer.msg(res.msg, {
-                            offset: '15px'
-                            , icon: 1
-                            , time: 1000
-                        });
-                    }
-
-                }
-            });
-        });
-        function getList(type) {
-            layui.define(['table', 'form'], function(exports){
-                var $ = layui.$
-                    ,table = layui.table
-                    ,form = layui.form;
-
-                var cols  = [
-                    {field: 'money', title: '充值金额',width:320,}
-                    ,{field: 'give_money',width:160, title: '赠送金额'}
-                    ,{field: 'recommend',width:160, title: '推荐',toolbar: '#recommend'}
-                    ,{field: 'sort',width: 80, title:'排序',event: 'tips',edit:'text',sort: true}
-                    ,{fixed: 'right', title: '操作', align: 'center', width:300, toolbar: '#recharge-operation'}
-                ];
-
-                table.render({
-                    id:'recharge-lists'
-                    ,elem: '#recharge-lists'
-                    ,url: '{:url("recharge/lists")}?type='+type  //模拟接口
-                    ,cols: [cols]
-                    ,text: {none: '暂无数据!'}
-                    ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
-                        if(type == 2){
-                            console.log(res)
-                            $('.give_growth').val(res.data[0].give_growth);
-                            $('.min_money').val(res.data[0].min_money);
-                            $("input[name=open_racharge][value="+res.data[0].open_racharge+"]").prop("checked",true);
-                            form.render();
-                        }else{
-                            return {
-                                "code":res.code,
-                                "msg":res.msg,
-                                "data": res.data, //解析数据列表
-                            };
-                        }
-
-                    },
-                    response: {
-                        statusCode: 1
-                    }
-                    ,done: function(res, curr, count){
-                        // 解决操作栏因为内容过多换行问题
-                        $(".layui-table-main tr").each(function (index, val) {
-                            $($(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height());
-                            $($(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height());
-                        });
-                    }
-
-                });
-
-            });
-        }
-        function changeFields(id,fields,value){
-            $.ajax({
-                url:'{:url("recharge/changeFields")}',
-                data:{id:id,field:fields,value:value},
-                type:'get',
-                dataType:'json',
-                success:function (res) {
-                    if(res.code == 1) {
-                        layui.layer.msg(res.msg, {
-                            offset: '15px'
-                            , icon: 1
-                            , time: 1000
-                        });
-                    }else {
-                        layui.layer.msg(res.msg, {
-                            offset: '15px'
-                            , icon: 2
-                            , time: 1000
-                        }, function () {
-                            if (fields === 'is_recommend') {
-                                window.location.href = window.location.href;
-                            }
-                        });
-                    }
-                }
-            })
-        }
-
-    });
-</script>

+ 0 - 66
app/common/logic/AccountLogLogic.php

@@ -1,66 +0,0 @@
-<?php
-namespace app\common\logic;
-
-use app\common\basics\Logic;
-use app\common\model\user\User;
-use app\common\model\AccountLog;
-use app\admin\logic\user\LevelLogic;
-
-class AccountLogLogic extends Logic
-{
-    /**
-     * Notes:记录会员账户流水,如果变动类型是成长值,且是增加的,则调用更新会员等级方法。该方法应在添加用户账户后调用
-     * @param int $user_id  用户id
-     * @param float $amount 变动数量
-     * @param int $change_type  变动类型:1-增加;2-减少
-     * @param int $source_type 来源类型
-     * @param string $remark 说明
-     * @param string $source_id 来源id
-     * @param string $source_sn 来源单号
-     * @param string $extra 额外字段说明
-     * @return bool
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     */
-    public static function AccountRecord($user_id,$amount,$change_type,$source_type,$remark ='',$source_id ='',$source_sn='',$extra=''){
-        $user = User::findOrEmpty($user_id);
-        if($user->isEmpty()){
-            return false;
-        }
-        $type = AccountLog::getChangeType($source_type);
-        $left_amount = 0;
-        switch ($type){
-            case 'money':
-                $left_amount = $user->user_money;
-                break;
-            case 'integral':
-                $left_amount = $user->user_integral;
-                break;
-            case 'growth':
-                $left_amount = $user->user_growth;
-                break;
-            case 'earnings':
-                $left_amount = $user->earnings;
-        }
-        $account_log = new AccountLog();
-        $account_log->log_sn = createSn('account_log','log_sn','',4);
-        $account_log->user_id = $user_id;
-        $account_log->source_type = $source_type;
-        $account_log->source_id = $source_id;
-        $account_log->source_sn = $source_sn;
-        $account_log->change_amount = $amount;
-        $account_log->left_amount = $left_amount;
-        $account_log->remark = AccountLog::getRemarkDesc($source_type,$source_sn,$remark);
-        $account_log->extra = $extra;
-        $account_log->change_type = $change_type;
-        $account_log->create_time = time();
-        $account_log->save();
-
-        //更新会员等级
-        if($type === 'growth' && $change_type == 1){
-            LevelLogic::updateUserLevel([$user]);
-        }
-        return true;
-    }
-}

+ 0 - 37
app/common/logic/AfterSaleLogLogic.php

@@ -1,37 +0,0 @@
-<?php
-
-namespace app\common\logic;
-
-use app\common\enum\OrderLogEnum;
-use app\common\model\after_sale\AfterSaleLog;
-use app\common\model\order\OrderLog;
-use think\Model;
-
-/**
- * 售后记录日志
- * Class OrderLogLogic
- * @package app\common\logic
- */
-class AfterSaleLogLogic
-{
-    public static function record($type, $channel, $order_id, $after_sale_id, $handle_id, $content, $desc = '')
-    {
-        if (empty($content)) {
-            return true;
-        }
-        $log = new AfterSaleLog();
-        $log->type = $type;
-        $log->channel = $channel;
-        $log->order_id = $order_id;
-        $log->after_sale_id = $after_sale_id;
-        $log->handle_id = $handle_id;
-        $log->content = AfterSaleLog::getLogDesc($content);
-        $log->create_time = time();
-
-        if ($desc != ''){
-            $log->content = AfterSaleLog::getLogDesc($content).'('.$desc.')';
-        }
-
-        $log->save();
-    }
-}

+ 0 - 61
app/common/logic/DistributionLogic.php

@@ -1,61 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\common\logic;
-
-use app\common\model\distribution\Distribution;
-use app\common\model\distribution\DistributionLevel;
-use app\common\server\ConfigServer;
-
-/**
- * 分销基础信息逻辑层
- * Class DistributionLogic
- * @package app\common\logic
- */
-class DistributionLogic
-{
-    /**
-     * @notes 添加分销基础信息记录
-     * @param $userId
-     * @author Tab
-     * @date 2021/9/2 11:55
-     */
-    public static function add($userId)
-    {
-        // 默认分销会员等级
-        $defaultLevelId = DistributionLevel::where('is_default', 1)->value('id');
-        // 分销会员开通方式
-        $apply_condition = ConfigServer::get('distribution', 'apply_condition', 2);
-        $isDistribution = $apply_condition == 1 ? 1 : 0;
-
-        $data = [
-            'user_id' => $userId,
-            'level_id' => $defaultLevelId,
-            'is_distribution' => $isDistribution,
-            'is_freeze' => 0,
-            'remark' => '',
-        ];
-
-        if($isDistribution) {
-            // 成为分销会员时间
-            $data['distribution_time'] = time();
-        }
-
-        Distribution::create($data);
-    }
-}

+ 0 - 249
app/common/logic/FreightLogic.php

@@ -1,249 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\common\logic;
-
-use app\common\model\Freight;
-use app\common\model\FreightConfig;
-use think\facade\Db;
-use think\Exception;
-
-class FreightLogic
-{
-
-    public static function lists($get)
-    {
-        $freight = new Freight();
-        $where = [];
-
-        if (isset($get['name']) && $get['name'] != '') {
-            $where[] = ['name', 'like', '%' . $get['name'] . '%'];
-        }
-
-        if (isset($get['charge_way']) && $get['charge_way'] != '') {
-            $where[] = ['charge_way', '=', $get['charge_way']];
-        }
-
-        if (isset($get['shop_id'])){
-            $where[] = ['shop_id','=',$get['shop_id']];
-        }
-        $count = $freight->where($where)->count();
-        $list = $freight
-            ->where($where)
-            ->page($get['page'], $get['limit'])
-            ->append(['charge_way_text'])
-            ->order('id desc')
-            ->select();
-
-        if (!$list) {
-            return ['count' => '', 'lists' => []];
-        }
-
-        return ['count' => $count, 'lists' => $list];
-    }
-
-
-
-
-
-    public static function add($post)
-    {
-        $freight = new Freight();
-        $freight->name = $post['name'];
-        $freight->charge_way = $post['charge_way'];
-        $freight->remark = $post['remark'];
-        $freight->shop_id = $post['shop_id'];
-        $freight->allowField(['name','charge_way','remark','shop_id'])->save();
-
-        $freight_config = new FreightConfig();
-
-        $config_data = [];
-        foreach ($post as &$item) {
-            if (is_array($item)) {
-                $item = array_values($item);
-            }
-        }
-
-        $post = form_to_linear($post);
-        foreach ($post as $v) {
-            $v['freight_id'] = $freight->id;
-            $v['create_time'] = time();
-            $config_data[] = $v;
-        }
-        $freight_config->allowField(['region','first_unit','first_money','continue_unit','continue_money','freight_id','create_time'])->insertAll($config_data);
-    }
-
-
-    public static function edit($post)
-    {
-        Db::startTrans();
-        try {
-            $freight = Freight::where(['id' => $post['id']])
-                ->with('configs')
-                ->find();
-
-            //删除之前保存的配置,再增加
-            FreightConfig::where(['freight_id' => $freight['id']])->delete();
-
-            $freight->where('id',$freight['id'])->save([
-                'name' => $post['name'],
-                'charge_way' => $post['charge_way'],
-                'remark' => $post['remark'],
-            ]);
-
-
-            $config_data = [];
-            foreach ($post as &$item) {
-                if (is_array($item)) {
-                    $item = array_values($item);
-                }
-            }
-
-            $post = form_to_linear($post);
-
-            foreach ($post as $v) {
-                $v['freight_id'] = $freight->id;
-                $config_data[] = $v;
-            }
-
-            $freight_config = new FreightConfig();
-            $freight_config->allowField(['region','first_unit','first_money','continue_unit','continue_money','freight_id','create_time'])->insertAll($config_data);
-            Db::commit();
-        } catch (Exception $e) {
-            Db::rollback();
-        }
-    }
-
-
-    public static function del($post)
-    {
-        Db::startTrans();
-        try {
-            Freight::where(['id' => $post['id']])->delete();
-            FreightConfig::where(['freight_id' => $post['id']])->delete();
-            Db::commit();
-        } catch (Exception $e) {
-            Db::rollback();
-        }
-    }
-
-
-    public static function detail($id)
-    {
-        $freight = Freight::where(['id' => $id])
-            ->with('configs')
-            ->append(['charge_way_text'])
-            ->find()->toArray();
-
-
-        $regions = Db::name('dev_region')->column('name', 'id');
-
-        foreach ($freight['configs'] as &$item) {
-            $item['region_name'] = '';
-
-            if ($item['region'] == 'all'){
-                $item['region_name'] = '全国';
-                continue;
-            }
-
-            $region = explode(',', $item['region']);
-
-            foreach ($region as $v) {
-                if (isset($regions[$v])) {
-                    $item['region_name'] .= $regions[$v] . ',';
-                }
-            }
-            $item['region_name'] = rtrim($item['region_name'], ',');
-        }
-        return $freight;
-    }
-
-    public static function areaTree()
-    {
-        $lists = Db::name('dev_region')
-            ->field('id,parent_id,level,name as title')
-            ->order('parent_id', 'desc')
-            ->select();
-
-        $result = self::areaSort($lists);
-        return $result;
-    }
-
-    public static function areaSort(&$lists)
-    {
-        $tree = [];
-        foreach ($lists as $k1 => $province) {
-            if ($province['level'] == 1) {
-
-                //树形结构参数
-                $province['checkArr']['type'] = 0;
-                $province['checkArr']['checked'] = 0;
-                $province['last'] = false;
-                $province['parentId'] = -1;
-
-                //钓鱼岛这个没有下级
-                if ($province['id'] == 900000) {
-                    $province['children'] = [];
-                    $province['last'] = true;
-                }
-
-                $tree[$k1] = $province;
-                unset($lists[$k1]);
-                foreach ($lists as $k2 => $city) {
-                    $city['parentId'] = $city['parent_id'];
-                    if ($city['parentId'] == $province['id']) {
-                        foreach ($lists as $k3 => $district) {
-                            $district['parentId'] = $district['parent_id'];
-                            if ($district['parentId'] == $city['id']) {
-
-                                //树形结构参数
-                                $district['checkArr']['type'] = 0;
-                                $district['checkArr']['checked'] = 0;
-                                $district['last'] = true;
-
-                                $city['children'][] = $district;
-                                unset($lists[$k3]);
-                            }
-                        }
-
-                        //树形结构参数
-                        $city['checkArr']['type'] = 0;
-                        $city['checkArr']['checked'] = 0;
-                        $city['last'] = false;
-
-                        $tree[$k1]['children'][] = $city;
-                        unset($lists[$k2]);
-                    }
-                }
-            }
-        }
-        return array_values($tree);
-    }
-
-
-    /**
-     * note 获取全部运费模板
-     */
-    public static function getFreightList()
-    {
-        return  Db::name('freight')->field('id,name')->select();
-    }
-
-
-}

+ 0 - 126
app/common/logic/GoodsVirtualLogic.php

@@ -1,126 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\common\logic;
-
-
-use app\common\enum\GoodsEnum;
-use app\common\enum\OrderEnum;
-use app\common\model\goods\Goods;
-use app\common\model\order\Order;
-
-/**
- * 虚拟商品逻辑
- * Class GoodsVirtualLogic
- * @package app\common\logic
- */
-class GoodsVirtualLogic
-{
-
-    /**
-     * @notes 订单之后虚拟配送
-     * @param $orderIds
-     * @return bool
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2022/4/12 11:37
-     */
-    public static function afterPayVirtualDelivery($orderIds)
-    {
-        $orderIds = is_array($orderIds) ? $orderIds : [$orderIds];
-        $orders = Order::with(['order_goods'])->whereIn('id', $orderIds)->select()->toArray();
-
-        foreach ($orders as $order) {
-
-            $goodsId = $order['order_goods'][0]['goods_id'] ?? 0;
-            $goods = Goods::findOrEmpty($goodsId);
-
-            // 商品不存在,不是虚拟商品,买家付款后不是自动发货
-            if ($goods->isEmpty() || $goods['type'] != GoodsEnum::TYPE_VIRTUAL) {
-                continue;
-            }
-
-            $data = [
-                'delivery_content' => $goods['delivery_content'],
-                'update_time' => time(),
-            ];
-
-            // 商品为支付后自动发货
-            if ($goods['after_pay'] == GoodsEnum::AFTER_PAY_AUTO_DELIVERY) {
-                $data['order_status'] = OrderEnum::ORDER_STATUS_GOODS; // 待收货状态
-                $data['delivery_type'] = OrderEnum::DELIVERY_TYPE_VIRTUAL; // 发货方式为虚拟发货
-                $data['shipping_status'] = OrderEnum::SHIPPING_FINISH; // 已发货
-                $data['shipping_time'] = time();
-
-                // 自动完成订单
-                if ($goods['after_delivery'] == GoodsEnum::AFTER_DELIVERY_AUTO_COMFIRM) {
-                    $data['order_status'] = OrderEnum::ORDER_STATUS_COMPLETE;// 已完成
-                    $data['confirm_take_time'] = time();
-                }
-            }
-            Order::where(['id' => $order['id']])->update($data);
-        }
-
-        return true;
-    }
-
-
-
-    /**
-     * @notes 商家手动发货
-     * @param $orderId
-     * @param null $content
-     * @return bool|string
-     * @author 段誉
-     * @date 2022/4/12 11:44
-     */
-    public static function shopSelfDelivery($orderId, $content = null)
-    {
-        $order = Order::with(['order_goods'])->where('id', $orderId)->findOrEmpty()->toArray();
-
-        $goodsId = $order['order_goods'][0]['goods_id'] ?? 0;
-        $goods = Goods::findOrEmpty($goodsId);
-
-        // 商品不存在,不是虚拟商品,买家付款后不是自动发货
-        if ($goods->isEmpty() || $goods['type'] != GoodsEnum::TYPE_VIRTUAL) {
-            return '虚拟商品信息不存在';
-        }
-
-        $data = [
-            'order_status' => OrderEnum::ORDER_STATUS_GOODS, // 待收货状态
-            'delivery_type' => OrderEnum::DELIVERY_TYPE_VIRTUAL, // 发货方式为虚拟发货
-            'delivery_content' => empty($content) ? $goods['delivery_content'] : $content,
-            'shipping_status' => OrderEnum::SHIPPING_FINISH, // 已发货
-            'shipping_time' => time(),
-            'update_time' => time(),
-        ];
-
-        // 自动完成订单
-        if ($goods['after_delivery'] == GoodsEnum::AFTER_DELIVERY_AUTO_COMFIRM) {
-            $data['order_status'] = OrderEnum::ORDER_STATUS_COMPLETE;// 已完成
-            $data['confirm_take_time'] = time();
-        }
-        Order::where(['id' => $order['id']])->update($data);
-        return true;
-    }
-
-
-}

+ 0 - 309
app/common/logic/IntegralOrderRefundLogic.php

@@ -1,309 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\common\logic;
-
-
-use app\common\enum\IntegralGoodsEnum;
-use app\common\enum\IntegralOrderEnum;
-use app\common\enum\PayEnum;
-use app\common\model\integral\IntegralGoods;
-use app\common\model\integral\IntegralOrder;
-use app\common\model\AccountLog;
-use app\common\model\integral\IntegralOrderRefund;
-use app\common\model\user\User;
-use app\common\server\AliPayServer;
-use app\common\server\DouGong\pay\PayZhengsaoRefund;
-use app\common\server\WeChatPayServer;
-use app\common\server\WeChatServer;
-use think\Exception;
-
-/**
- * 积分订单退款逻辑
- * Class OrderRefundLogic
- * @package app\common\logic
- */
-class IntegralOrderRefundLogic
-{
-
-    /**
-     * @notes 取消订单(标记订单状态,退回库存,扣减销量)
-     * @param int $order_id
-     * @author 段誉
-     * @date 2022/3/3 11:01
-     */
-    public static function cancelOrder(int $order_id)
-    {
-        // 订单信息
-        $order = IntegralOrder::findOrEmpty($order_id);
-        $order->cancel_time = time();
-        $order->order_status = IntegralOrderEnum::ORDER_STATUS_DOWN;
-        $order->save();
-
-        // 订单商品信息
-        $goods_snap = $order['goods_snap'];
-        // 退回库存, 扣减销量
-        IntegralGoods::where([['id', '=', $goods_snap['id']], ['sales', '>=', $order['total_num']]])
-            ->inc('stock', $order['total_num'])
-            ->dec('sales', $order['total_num'])
-            ->update();
-    }
-
-
-    /**
-     * @notes 退回已支付金额
-     * @param int $order_id
-     * @return bool
-     * @throws Exception
-     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2022/3/3 16:00
-     */
-    public static function refundOrderAmount(int $order_id)
-    {
-        // 订单信息
-        $order = IntegralOrder::findOrEmpty($order_id);
-        // 订单商品信息
-        $goods_snap = $order['goods_snap'];
-
-        //已支付的商品订单,取消,退款
-        if ($goods_snap['type'] == IntegralGoodsEnum::TYPE_GOODS
-            && $order['refund_status'] == IntegralOrderEnum::NO_REFUND
-        ) {
-            if ($order['order_amount'] <= 0) {
-               return true;
-            }
-            // 更新订单退款状态为已退款
-            IntegralOrder::where(['id' => $order['id']])->update([
-                'refund_status' => IntegralOrderEnum::IS_REFUND,//订单退款状态; 0-未退款;1-已退款
-                'refund_amount' => $order['order_amount'],
-            ]);
-
-            // 发起退款
-            $refund_log = self::addRefundLog($order, $order['order_amount'], 1, $order['order_amount']);
-
-            switch ($order['pay_way']) {
-                //余额退款
-                case PayEnum::BALANCE_PAY:
-                    self::balancePayRefund($order, $order['order_amount']);
-                    break;
-                //微信退款
-                case PayEnum::WECHAT_PAY:
-                    self::wechatPayRefund($order, $refund_log);
-                    break;
-                //支付宝退款
-                case PayEnum::ALI_PAY:
-                    self::aliPayRefund($order, $refund_log);
-                    break;
-                case PayEnum::HFDG_WECHAT:
-                case PayEnum::HFDG_ALIPAY:
-                    $payZsRefund = new PayZhengsaoRefund([
-                        'refund'    => [
-                            'id'                => $refund_log['id'],
-                            'money'             => $order['order_amount'],
-                        ],
-                        'order'     => [
-                            'id'                => $order['id'],
-                            'transaction_id'    => $order['transaction_id'],
-                            'hfdg_params'       => $order['hfdg_params'],
-                        ],
-                        'from'      => 'integral',
-                    ]);
-                    $result = $payZsRefund->request()->getRefundResult();
-                    if ($result['code'] != 1) {
-                        throw new \Exception($result['msg']);
-                    }
-                    break;
-            }
-        }
-        return true;
-    }
-
-
-    /**
-     * @notes 退回已支付积分
-     * @param $id
-     * @return bool
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2022/3/3 16:02
-     */
-    public static function refundOrderIntegral($id)
-    {
-        $order = IntegralOrder::findOrEmpty($id);
-        if ($order['order_integral'] > 0) {
-            // 退回积分
-            User::where(['id' => $order['user_id']])
-                ->inc('user_integral', $order['order_integral'])
-                ->update();
-
-            AccountLogLogic::AccountRecord(
-                $order['user_id'],
-                $order['order_integral'], 1,
-                AccountLog::cancel_integral_order,
-                '', $order['id'], $order['order_sn']
-            );
-
-            IntegralOrder::where(['id' => $id])->update([
-                'refund_integral' => $order['order_integral']
-            ]);
-        }
-        return true;
-    }
-
-
-
-    /**
-     * @notes 增加退款记录
-     * @param $order
-     * @param $refund_amount
-     * @param $status
-     * @param string $msg
-     * @return IntegralOrderRefund|\think\Model
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2022/3/3 14:51
-     */
-    public static function addRefundLog($order, $refund_amount, $status, $msg = '')
-    {
-        return IntegralOrderRefund::create([
-            'order_id' => $order['id'],
-            'user_id' => $order['user_id'],
-            'refund_sn' => createSn('order_refund', 'refund_sn'),
-            'order_amount' => $order['order_amount'],
-            'refund_amount' => $refund_amount,
-            'transaction_id' => $order['transaction_id'],
-            'create_time' => time(),
-            'refund_status' => $status,
-            'refund_at' => time(),
-            'refund_msg' => json_encode($msg, JSON_UNESCAPED_UNICODE),
-        ]);
-    }
-
-
-    /**
-     * @notes 微信支付退款
-     * @param $order
-     * @param $refund_id
-     * @throws Exception
-     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
-     * @author 段誉
-     * @date 2022/3/3 14:52
-     */
-    public static function wechatPayRefund($order, $refund)
-    {
-        $config = WeChatServer::getPayConfigBySource($order['order_source'])['config'];
-        if (empty($config)) {
-            throw new Exception('请联系管理员设置微信相关配置!');
-        }
-        if (!isset($config['cert_path']) || !isset($config['key_path'])) {
-            throw new Exception('请联系管理员设置微信证书!');
-        }
-        if (!file_exists($config['cert_path']) || !file_exists($config['key_path'])) {
-            throw new Exception('微信证书不存在,请联系管理员!');
-        }
-
-        $result = WeChatPayServer::refund($config, [
-            'transaction_id' => $order['transaction_id'],
-            'refund_sn' => $refund['refund_sn'],
-            'total_fee' => intval(strval($refund['order_amount'] * 100)),//订单金额,单位为分
-            'refund_fee' => intval(strval($refund['refund_amount'] * 100)),//退款金额
-        ]);
-
-        if (isset($result['return_code']) && $result['return_code'] == 'FAIL') {
-            throw new Exception($result['return_msg']);
-        }
-        if (isset($result['err_code_des'])) {
-            throw new Exception($result['err_code_des']);
-        }
-        if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS') {
-            //更新退款日志记录
-            IntegralOrderRefund::where(['id' => $refund['id']])->update([
-                'wechat_refund_id' => $result['refund_id'] ?? 0,
-                'refund_msg' => json_encode($result, JSON_UNESCAPED_UNICODE),
-            ]);
-        } else {
-            throw new Exception('微信支付退款失败');
-        }
-    }
-
-
-    /**
-     * @notes 支付宝退款
-     * @param $order
-     * @param $refund_id
-     * @throws Exception
-     * @author 段誉
-     * @date 2022/3/3 14:52
-     */
-    public static function aliPayRefund($order, $refund)
-    {
-        $result = (new AliPayServer())->refund($order['order_sn'], $order['order_amount']);
-        // $result = (array)$result;
-        if ($result['code'] == '10000' && $result['msg'] == 'Success' && $result['fund_change'] == 'Y') {
-            //更新退款日志记录
-            IntegralOrderRefund::where(['id' => $refund])->update([
-                'refund_msg' => json_encode($result, JSON_UNESCAPED_UNICODE),
-            ]);
-        } else {
-            throw new Exception('支付宝退款失败');
-        }
-    }
-
-
-
-    /**
-     * @notes 余额退款
-     * @param $order
-     * @param $refund_amount
-     * @return bool
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2022/3/3 14:52
-     */
-    public static function balancePayRefund($order, $refund_amount)
-    {
-        $user = User::find($order['user_id']);
-        $user->user_money = ['inc', $refund_amount];
-        $user->save();
-
-        AccountLogLogic::AccountRecord(
-            $order['user_id'],
-            $refund_amount,
-            1,
-            AccountLog::cancel_order_refund,
-            '',
-            $order['id'],
-            $order['order_sn']
-        );
-        return true;
-    }
-
-
-
-}

+ 0 - 51
app/common/logic/OrderLogLogic.php

@@ -1,51 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\common\logic;
-
-use app\common\enum\OrderLogEnum;
-use app\common\model\order\OrderLog;
-
-/**
- * 订单记录日志
- * Class OrderLogLogic
- * @package app\common\logic
- */
-class OrderLogLogic
-{
-    public static function record($type, $channel, $order_id, $handle_id, $content, $desc = '')
-    {
-        if (empty($content)) {
-            return true;
-        }
-        $log = new OrderLog();
-        $log->type = $type;
-        $log->order_id = $order_id;
-        $log->channel = $channel;
-        $log->handle_id = $handle_id;
-        $log->content = OrderLogEnum::getLogDesc($content);
-        $log->create_time = time();
-
-        if ($desc != '') {
-            $log->content = OrderLogEnum::getLogDesc($content) . '(' . $desc . ')';
-        }
-
-        $log->save();
-    }
-}

+ 0 - 414
app/common/logic/OrderRefundLogic.php

@@ -1,414 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\common\logic;
-
-
-use app\common\enum\OrderEnum;
-use app\common\enum\OrderGoodsEnum;
-use app\common\enum\OrderLogEnum;
-use app\common\enum\OrderRefundEnum;
-use app\common\enum\PayEnum;
-use app\common\model\order\Order;
-use app\common\model\AccountLog;
-use app\common\model\order\Order as CommonOrder;
-use app\common\model\order\OrderGoods;
-use app\common\model\order\OrderLog;
-use app\common\model\Pay;
-use app\common\model\user\User;
-use app\common\server\AliPayServer;
-use app\common\server\DouGong\pay\PayZhengsaoRefund;
-use app\common\server\WeChatPayServer;
-use app\common\server\WeChatServer;
-use think\Exception;
-use think\facade\Db;
-use think\facade\Event;
-use think\facade\Log;
-
-/**
- * 订单退款逻辑
- * Class OrderRefundLogic
- * @package app\common\logic
- */
-class OrderRefundLogic
-{
-
-    /**
-     * Notes:  取消订单
-     * @param $order_id
-     * @param int $handle_type
-     * @param int $handle_id
-     * @author 段誉(2021/1/28 15:23)
-     * @return Order
-     */
-    public static function cancelOrder($order_id, $handle_type = OrderLogEnum::TYPE_SYSTEM, $handle_id = 0)
-    {
-        //更新订单状态
-//        $order = order::get($order_id);
-        $order = Order::where('id',$order_id)->find();
-        $order->order_status = OrderEnum::ORDER_STATUS_DOWN;
-        $order->update_time = time();
-        $order->cancel_time = time();
-        $order->save();
-
-        // 取消订单后的操作
-        switch ($handle_type) {
-            case OrderLogEnum::TYPE_USER:
-                $channel = OrderLogEnum::USER_CANCEL_ORDER;
-                break;
-            case OrderLogEnum::TYPE_SHOP:
-                $channel = OrderLogEnum::SHOP_CANCEL_ORDER;
-                break;
-            case OrderLogEnum::TYPE_SYSTEM:
-                $channel = OrderLogEnum::SYSTEM_CANCEL_ORDER;
-                break;
-        }
-
-        event('AfterCancelOrder', [
-            'type'    => $handle_type,
-            'channel'    => $channel,
-            'order_id'    => $order->id,
-            'handle_id' => $handle_id,
-        ]);
-    }
-
-
-    /**
-     * @notes 处理订单退款(事务在取消订单逻辑处)
-     * @param $order
-     * @param $order_amount
-     * @param $refund_amount
-     * @return bool
-     * @throws Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2021/12/20 15:13
-     */
-    public static function refund($order, $order_amount, $refund_amount,$refund_way = OrderRefundEnum::REFUND_WAY_ORIGINAL)
-    {
-        //退款记录
-        $refund_id = self::addRefundLog($order, $order_amount, $refund_amount);
-
-        if ($refund_amount <= 0) {
-            return false;
-        }
-
-        $pay_way = $order['pay_way'];
-        if ($refund_way == OrderRefundEnum::REFUND_WAY_BALANCE) {
-            $pay_way = PayEnum::BALANCE_PAY;
-        }
-        switch ($pay_way) {
-            //余额退款
-            case PayEnum::BALANCE_PAY:
-                self::balancePayRefund($order, $refund_amount);
-                break;
-            //微信退款
-            case PayEnum::WECHAT_PAY:
-                self::wechatPayRefund($order, $refund_id);
-                break;
-            //支付宝退款
-            case PayEnum::ALI_PAY:
-                self::aliPayRefund($order, $refund_id);
-                break;
-            case PayEnum::HFDG_WECHAT:
-            case PayEnum::HFDG_ALIPAY:
-                $payZsRefund = new PayZhengsaoRefund([
-                    'refund'    => [
-                        'id'                => $refund_id,
-                        'money'             => $refund_amount,
-                    ],
-                    'order'     => [
-                        'id'                => $order['id'],
-                        'transaction_id'    => $order['transaction_id'],
-                        'hfdg_params'       => $order['hfdg_params'],
-                    ],
-                    'from'      => 'order',
-                ]);
-                $result = $payZsRefund->request()->getRefundResult();
-                if ($result['code'] != 1) {
-                    throw new \Exception($result['msg']);
-                }
-                break;
-        }
-
-        return true;
-    }
-
-
-    /**
-     * Notes: 微信支付退款
-     * @param $order mixed (订单信息)
-     * @param $refund_id mixed (退款记录id) 
-     * @author 段誉(2021/1/27 16:04)
-     * @throws Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     * @throws \think\exception\PDOException
-     */
-    public static function wechatPayRefund($order, $refund_id)
-    {
-        $config = WeChatServer::getPayConfigBySource($order['order_source'])['config'];
-
-        if (empty($config)) {
-            throw new Exception('请联系管理员设置微信相关配置!');
-        }
-
-        if (!isset($config['cert_path']) || !isset($config['key_path'])) {
-            throw new Exception('请联系管理员设置微信证书!');
-        }
-        if (!file_exists($config['cert_path']) || !file_exists($config['key_path'])) {
-            throw new Exception('微信证书不存在,请联系管理员!');
-        }
-
-        $refund_log = Db::name('order_refund')->where(['id' => $refund_id])->find();
-        $total_fee = Db::name('order_trade')->where(['transaction_id' => $order['transaction_id']])->value('order_amount');
-        // 单独支付的子订单 父订单未记录transaction_id 使用子订单的金额
-        $total_fee = $total_fee ? : $order['order_amount'];
-        $data = [
-            'transaction_id'    => $order['transaction_id'],
-            'refund_sn'         => $refund_log['refund_sn'],
-            'total_fee'         => bcmul($total_fee, 100),//订单金额,单位为分
-            'refund_fee'        => bcmul($refund_log['refund_amount'], 100),//退款金额
-        ];
-
-        $result = WeChatPayServer::refund($config, $data);
-
-        if (isset($result['return_code']) && $result['return_code'] == 'FAIL') {
-            throw new Exception($result['return_msg']);
-        }
-
-        if (isset($result['err_code_des'])) {
-            throw new Exception($result['err_code_des']);
-        }
-
-        if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS') {
-            $update_data = [
-                'wechat_refund_id' => $result['refund_id'] ?? 0,
-                'refund_msg' => json_encode($result, JSON_UNESCAPED_UNICODE),
-            ];
-            //更新退款日志记录
-            Db::name('order_refund')->where(['id' => $refund_id])->update($update_data);
-
-        } else {
-            throw new Exception('微信支付退款失败');
-        }
-    }
-
-
-    /**
-     * Notes: 支付宝退款
-     * @param $order
-     * @param $refund_id
-     * @author 段誉(2021/3/23 15:48)
-     * @throws Exception
-     * @throws \think\exception\PDOException
-     */
-    public static function aliPayRefund($order, $refund_id)
-    {
-        $refund_log = Db::name('order_refund')->where(['id' => $refund_id])->find();
-        $trade_id   = $order['trade_id'];
-        $trade      = Db::name('order_trade')->where(['id' => $trade_id])->find();
-        $result     = (new AliPayServer())->refund($trade['t_sn'], $refund_log['refund_amount'], $refund_log['refund_sn']);
-        // $result = (array)$result
-
-        if ($result['code'] == '10000' && $result['msg'] == 'Success' && $result['fund_change'] == 'Y') {
-            //更新退款日志记录
-            $update_data = [ 'refund_msg' => json_encode($result['msg'], JSON_UNESCAPED_UNICODE) ];
-            Db::name('order_refund')->where(['id' => $refund_id])->update($update_data);
-        } else {
-            
-            $result = (new AliPayServer())->refund($order['order_sn'], $refund_log['refund_amount'], $refund_log['refund_sn']);
-            
-            // $result = (array)$result;
-            if ($result['code'] == '10000' && $result['msg'] == 'Success' && $result['fund_change'] == 'Y') {
-                //更新退款日志记录
-                $update_data = [ 'refund_msg' => json_encode($result['msg'], JSON_UNESCAPED_UNICODE) ];
-                Db::name('order_refund')->where(['id' => $refund_id])->update($update_data);
-            }else{
-                throw new Exception('支付宝退款失败');
-            }
-        }
-    }
-
-
-    /**
-     * Notes: 增加退款记录
-     * @param $order
-     * @param $order_amount
-     * @param $refund_amount
-     * @param string $result_msg
-     * @author 段誉(2021/1/28 15:23)
-     * @return int|string
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     */
-    public static function addRefundLog($order, $order_amount, $refund_amount, $result_msg = '退款成功')
-    {
-        $data = [
-            'order_id' => $order['id'],
-            'user_id' => $order['user_id'],
-            'refund_sn' => createSn('order_refund', 'refund_sn'),
-            'order_amount' => $order_amount,
-            'refund_amount' => $refund_amount,
-            'transaction_id' => $order['transaction_id'],
-            'create_time' => time(),
-            'refund_status' => 1,
-            'refund_at' => time(),
-            'refund_msg' => json_encode($result_msg, JSON_UNESCAPED_UNICODE),
-        ];
-        return Db::name('order_refund')->insertGetId($data);
-    }
-
-
-    /**
-     * Notes: 取消订单,退款后更新订单和订单商品信息
-     * @param $order
-     * @author 段誉(2021/1/28 14:21)
-     * @throws Exception
-     * @throws \think\exception\PDOException
-     */
-    public static function cancelOrderRefundUpdate($order)
-    {
-        //订单商品=>标记退款成功状态
-        Db::name('order_goods')
-            ->where(['order_id' => $order['id']])
-            ->update(['refund_status' => OrderGoodsEnum::REFUND_STATUS_SUCCESS]);
-
-        //更新订单支付状态为已退款
-        Db::name('order')->where(['id' => $order['id']])->update([
-            'pay_status' => PayEnum::REFUNDED,
-            'refund_status' => OrderEnum::REFUND_STATUS_ALL_REFUND,//订单退款状态; 0-未退款;1-部分退款;2-全部退款
-            'refund_amount' => $order['order_amount'],
-            'is_cancel' => OrderEnum::ORDER_CANCEL,
-        ]);
-    }
-
-
-    /**
-     * Notes:售后退款更新订单或订单商品状态
-     * @param $order
-     * @param $order_goods_id
-     * @author 段誉(2021/1/28 15:22)
-     */
-    public static function afterSaleRefundUpdate($order, $order_goods_id, $admin_id = 0)
-    {
-        $order_goods = OrderGoods::find(['id' => $order_goods_id]);
-        $order_goods->refund_status = OrderGoodsEnum::REFUND_STATUS_SUCCESS;//退款成功
-        $order_goods->save();
-
-        //更新订单状态
-        $order = Order::find(['id' => $order['id']]);
-        $order->pay_status = PayEnum::REFUNDED;
-        $order->refund_amount += $order_goods['total_pay_price'];//退款金额 + 以前的退款金额
-        $order->refund_status = 1;//退款状态:0-未退款;1-部分退款;2-全部退款
-
-        //如果订单商品已全部退款
-        if (self::checkOrderGoods($order['id'])) {
-            $order->order_status = CommonOrder::STATUS_CLOSE;
-            $order->refund_status = 2;
-
-            OrderLogLogic::record(
-                OrderLogEnum::TYPE_SHOP,
-                OrderLogEnum::SYSTEM_CANCEL_ORDER,
-                $order['id'],
-                $admin_id,
-                OrderLogEnum::getLogDesc(OrderLogEnum::SYSTEM_CANCEL_ORDER)
-            );
-        }
-        $order->save();
-    }
-
-
-    //订单内商品是否已全部
-    public static function checkOrderGoods($order_id)
-    {
-        $order_goods = OrderGoods::where('order_id', $order_id)->select();
-        if (empty($order_goods)) {
-            return false;
-        }
-
-        foreach ($order_goods as $item) {
-            if ($item['refund_status'] != OrderGoodsEnum::REFUND_STATUS_SUCCESS) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-
-    /**
-     * Notes: 余额退款
-     * @param $order
-     * @param $refund_amount
-     * @author 段誉(2021/1/28 15:24)
-     * @return bool
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     */
-    public static function balancePayRefund($order, $refund_amount)
-    {
-        $user = User::find($order['user_id']);
-        $user->user_money = ['inc', $refund_amount];
-        $user->save();
-
-        AccountLogLogic::AccountRecord(
-            $order['user_id'],
-            $refund_amount,
-            1,
-            AccountLog::cancel_order_refund,
-            '',
-            $order['id'],
-            $order['order_sn']
-        );
-        return true;
-    }
-
-
-    /**
-     * Notes: 退款失败增加错误记录
-     * @param $order
-     * @param $err_msg
-     * @author 段誉(2021/1/28 15:24)
-     * @return int|string
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     */
-    public static function addErrorRefund($order, $err_msg)
-    {
-        $refund_data = [
-            'order_id' => $order['id'],
-            'user_id' => $order['user_id'],
-            'refund_sn' => createSn('order_refund', 'refund_sn'),
-            'order_amount' => $order['order_amount'],//订单应付金额
-            'refund_amount' => $order['order_amount'],//订单退款金额
-            'transaction_id' => $order['transaction_id'],
-            'create_time' => time(),
-            'refund_status' => 2,
-            'refund_msg' => json_encode($err_msg, JSON_UNESCAPED_UNICODE),
-        ];
-        return Db::name('order_refund')->insertGetId($refund_data);
-    }
-
-}