parent
fca99fa2f7
commit
0bc3cb6bd4
|
|
@ -96,8 +96,40 @@ class User extends BaseModel{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Common: 赠送商品
|
||||
* Author: wu-hui
|
||||
* Time: 2023/02/23 13:58
|
||||
* @return array
|
||||
*/
|
||||
public function sendGoods(){
|
||||
// 获取参数信息
|
||||
$info = (array)input('info',[]);
|
||||
$memberId = (int)input('member_id',0);
|
||||
if($memberId <= 0) return $this->error('','用户信息错误!');
|
||||
// 赠送商品
|
||||
try{
|
||||
$time = time();
|
||||
$insert = [];
|
||||
for($i=0;$i<$info['order_num'];$i++){
|
||||
$insert[] = [
|
||||
'site_id' => $this->site_id,
|
||||
'member_id' => $memberId,
|
||||
'goods_id' => (int)$info['goods_id'],
|
||||
'total' => (int)$info['goods_num'],
|
||||
'unit_price' => sprintf("%.2f",$info['unit_price'] * $info['goods_num']),
|
||||
'status' => 1,
|
||||
'created_time' => $time,
|
||||
];
|
||||
}
|
||||
|
||||
Db::name('futures')->insertAll($insert);
|
||||
|
||||
return $this->success();
|
||||
}catch(Exception $e){
|
||||
return $this->error('',$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
namespace addon\futures\shop\controller;
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\futures\model\User as userModel;
|
||||
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
class User extends BaseShop{
|
||||
/**
|
||||
* Common: 进入首页
|
||||
|
|
@ -40,6 +40,14 @@ class User extends BaseShop{
|
|||
}
|
||||
|
||||
|
||||
// 商品赠送
|
||||
public function sendGoods(){
|
||||
if(request()->isAjax()) return (new userModel($this->site_id))->sendGoods();
|
||||
|
||||
$this->assign('member_id',input('member_id',0));
|
||||
return $this->fetch('user/send_goods');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -155,13 +155,16 @@
|
|||
});
|
||||
// 赠送商品
|
||||
function sendGoods(data){
|
||||
|
||||
|
||||
console.log(data);
|
||||
|
||||
|
||||
|
||||
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '赠送商品',
|
||||
skin: 'layer-tips-class',
|
||||
area: ['80%','90%'],
|
||||
content: ns.url("futures://shop/user/sendGoods", { member_id: data.member_id }),
|
||||
end: function(){
|
||||
table.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,207 @@
|
|||
{extend name="app/shop/view/base.html"/}
|
||||
{block name="resources"}
|
||||
<style>
|
||||
.tips{
|
||||
font-size: 13px;
|
||||
color: #cccccc;
|
||||
}
|
||||
.hide{
|
||||
display: none;
|
||||
}
|
||||
.goods-list{
|
||||
width: calc(100% - 230px);
|
||||
display: inline-flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
margin-left: 200px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.goods-list .goods-item{
|
||||
position: relative;
|
||||
margin-top: 10px;
|
||||
margin-right: 10px;
|
||||
display: inline-flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1px solid #cccccc;
|
||||
padding: 10px;
|
||||
}
|
||||
.goods-list .goods-item .image{
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.goods-list .goods-item .image .image-img{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.goods-list .goods-item .info{
|
||||
width: 150px;
|
||||
}
|
||||
.goods-list .goods-item .info .name{
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical; /*设置对齐模式*/
|
||||
-webkit-line-clamp: 2; /*设置多行的行数*/
|
||||
}
|
||||
.goods-list .goods-item .del-button{
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
font-size: 25px;
|
||||
color: #e30000;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
{/block}
|
||||
|
||||
{block name="body"}
|
||||
<div class="layui-form form-wrap" lay-filter="formInfo">
|
||||
<div class="layui-form-item" id="upgrade_goods">
|
||||
<label class="layui-form-label img-upload-lable short-label">选择商品:</label>
|
||||
<div class="layui-input-inline">
|
||||
<button type="button" class="layui-btn select-member" onclick="selectGoods()">选择商品</button>
|
||||
</div>
|
||||
<div class="goods-list" id="goodsList"></div>
|
||||
</div>
|
||||
<div class="params-content hide">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label img-upload-lable short-label"><span class="required">*</span>订单数量:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" name="info[order_num]" value="1" lay-verify="required|number" min="1" placeholder="请输入订单数量" autocomplete="off" class="layui-input len-long">
|
||||
<div class="tips">赠送的订单数量</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label img-upload-lable short-label"><span class="required">*</span>商品数量:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" name="info[goods_num]" value="1" lay-verify="required|number" min="1" placeholder="请输入商品数量!" autocomplete="off" class="layui-input len-long">
|
||||
<div class="tips">每份订单中商品的数量</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label img-upload-lable short-label"><span class="required">*</span>初始均价:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" name="info[unit_price]" value="0" lay-verify="required|number" placeholder="请输入初始价格!" autocomplete="off" class="layui-input len-long">
|
||||
<div class="tips">所有订单的初始均价,订单均价(该价格除以商品数量)不能超过<span id="maxAverage">0</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--提交按钮-->
|
||||
<div class="form-row">
|
||||
<!--其他内容-->
|
||||
<input type="hidden" name="member_id" value="{$member_id}" />
|
||||
<!--操作按钮-->
|
||||
<button class="layui-btn" lay-submit lay-filter="save">提交</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="closeIframe()">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
{block name="script"}
|
||||
<script>
|
||||
var _thisIndex,form,repeat_flag = false,goods_info = {};
|
||||
$(function () {
|
||||
// 基本参数
|
||||
_thisIndex = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
|
||||
// 表单内容
|
||||
layui.use(['form'], function() {
|
||||
form = layui.form;
|
||||
form.render();
|
||||
// 表单提交
|
||||
form.on('submit(save)', function(data){
|
||||
var field = data.field;
|
||||
// 判断信息是否完整
|
||||
if(!field['info[goods_id]'] || parseInt(field['info[goods_id]']) <= 0){
|
||||
layer.msg('请选择商品!');
|
||||
return false;
|
||||
}
|
||||
if(field['info[unit_price]'] < goods_info['price']){
|
||||
layer.msg('商品价格不能低于售卖价格!');
|
||||
return false;
|
||||
}
|
||||
if(field['info[unit_price]'] >= goods_info['market_price']){
|
||||
layer.msg('商品价格必须低于原价(划线价)!');
|
||||
return false;
|
||||
}
|
||||
// 数据提交
|
||||
let tips = '确认赠送当前用户[' + field['info[order_num]'] + ']个订单,每个订单拥有[' + field['info[goods_num]'] +']个商品';
|
||||
layer.confirm(tips, {icon: 3, title:'提示'}, function(index){
|
||||
layer.close(index);
|
||||
if(repeat_flag) return;
|
||||
//repeat_flag = true;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("futures://shop/user/sendGoods"),
|
||||
data: field,
|
||||
async: false,
|
||||
success: function(res){
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
layer.alert('赠送成功', function(index){
|
||||
parent.layer.close(_thisIndex);
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
// 点击关闭弹框
|
||||
function closeIframe() {
|
||||
parent.layer.close(_thisIndex); //再执行关闭
|
||||
}
|
||||
// 选择商品
|
||||
function selectGoods(){
|
||||
var body;
|
||||
editIframe = layer.open({
|
||||
type: 2,
|
||||
title: '选择商品',
|
||||
skin: 'layer-tips-class',
|
||||
area: ['80%','90%'],
|
||||
content: ns.url("/shop/goods/selectGoods"),
|
||||
success: function (layero, index) {
|
||||
body = layui.layer.getChildFrame('body', index);//获取子窗体 body内容
|
||||
},
|
||||
end: function () {
|
||||
var info = body.contents().find("#selectGoodsInfo").val(); //获取input的内容
|
||||
if(info){
|
||||
// 信息记录
|
||||
goods_info = info = JSON.parse(info);
|
||||
$("#maxAverage").html(info.market_price);
|
||||
$("[name='info[unit_price]']").val(info.price);
|
||||
$(".params-content").removeClass('hide');
|
||||
rendering(info);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// 渲染商品信息
|
||||
function rendering(info){
|
||||
let html = '<div class="goods-item" id="goods_list_'+info['goods_id']+'">\n' +
|
||||
' <input type="hidden" name="info[goods_id]" value="'+info['goods_id']+'" />\n' +
|
||||
' <div class="image">\n' +
|
||||
' <img class="image-img" src="'+info['goods_image']+'" />\n' +
|
||||
' </div>\n' +
|
||||
' <div class="info">\n' +
|
||||
' <div class="name">'+info['goods_name']+'</div>\n' +
|
||||
' <div class="id">ID:'+info['goods_id']+'</div>\n' +
|
||||
' </div>\n' +
|
||||
' </div>';
|
||||
$("#goodsList").html(html)
|
||||
}
|
||||
</script>
|
||||
{/block}
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
*/
|
||||
|
||||
namespace app\model;
|
||||
use think\facade\Cache;
|
||||
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
|
||||
|
||||
|
|
@ -19,9 +21,13 @@ class NewBaseModel extends \think\Model{
|
|||
protected $name = false;
|
||||
protected $autoWriteTimestamp = false; // 开启自动时间戳
|
||||
protected $deleteTime = false; // 软删除字段
|
||||
protected $site_id;
|
||||
|
||||
public function __construct(array $data = []){
|
||||
parent::__construct($data);
|
||||
|
||||
$data['table_name'] = $this->name ?? $data['table_name'];
|
||||
|
||||
if($data['table_name']) {
|
||||
cache('new_model_table_name',$data['table_name']);
|
||||
$tableName = $data['table_name'];
|
||||
|
|
@ -30,9 +36,66 @@ class NewBaseModel extends \think\Model{
|
|||
}
|
||||
|
||||
$this->name = $tableName;
|
||||
$this->site_id = (int)request()->siteid();
|
||||
}
|
||||
|
||||
// 操作成功返回值函数
|
||||
public function success($data = '',$code_var = 'SUCCESS'){
|
||||
$lang_array = $this->getLang();
|
||||
$lang_var = isset($lang_array[$code_var]) ? $lang_array[$code_var] : $code_var;
|
||||
if($code_var == 'SUCCESS'){
|
||||
$code_var = 0;
|
||||
}
|
||||
else{
|
||||
$code_array = array_keys($lang_array);
|
||||
$code_index = array_search($code_var,$code_array);
|
||||
if($code_index != FALSE){
|
||||
$code_var = 10000 + $code_index;
|
||||
}
|
||||
}
|
||||
return success($code_var,$lang_var,$data);
|
||||
}
|
||||
// 操作失败返回值函数
|
||||
public function error($data = '',$code_var = 'FAIL'){
|
||||
|
||||
|
||||
$lang_array = $this->getLang();
|
||||
if(isset($lang_array[$code_var])){
|
||||
$lang_var = $lang_array[$code_var];
|
||||
}
|
||||
else{
|
||||
$lang_var = $code_var;
|
||||
$code_var = 'FAIL';
|
||||
}
|
||||
$code_array = array_keys($lang_array);
|
||||
$code_index = array_search($code_var,$code_array);
|
||||
if($code_index != FALSE){
|
||||
$code_var = -10000 - $code_index;
|
||||
}
|
||||
return error($code_var,$lang_var,$data);
|
||||
}
|
||||
// 获取语言包数组
|
||||
public function getLang(){
|
||||
$default_lang = config("lang.default_lang");
|
||||
$cache_common = Cache::get("lang_app/lang/".$default_lang.'/model.php');
|
||||
if(empty($cache_common)){
|
||||
$cache_common = include 'app/lang/'.$default_lang.'/model.php';
|
||||
Cache::tag("lang")
|
||||
->set("lang_app/lang/".$default_lang,$cache_common);
|
||||
}
|
||||
$lang_path = isset($this->lang) ? $this->lang : '';
|
||||
if(!empty($lang_path)){
|
||||
$cache_path = Cache::get("lang_".$lang_path."/".$default_lang.'/model.php');
|
||||
if(empty($cache_path)){
|
||||
$cache_path = include $lang_path."/".$default_lang.'/model.php';
|
||||
Cache::tag("lang")
|
||||
->set("lang_".$lang_path."/".$default_lang,$cache_path);
|
||||
}
|
||||
$lang = array_merge($cache_common,$cache_path);
|
||||
}
|
||||
else{
|
||||
$lang = $cache_common;
|
||||
}
|
||||
return $lang;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
<?php
|
||||
/** ZJMall商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2022-2032 四川正今科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.zjphp.com
|
||||
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布传播。
|
||||
* 唯一发布渠道官方颁发授权证书,无纸质授权凭证书视为侵权行为。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\newModel;
|
||||
|
||||
use app\model\NewBaseModel;
|
||||
use think\Exception;
|
||||
use think\facade\Cache;
|
||||
|
||||
class Config extends NewBaseModel{
|
||||
|
||||
protected $pk = 'id'; // 默认主键id
|
||||
protected $name = 'config';
|
||||
//protected $autoWriteTimestamp = false; // 开启自动时间戳
|
||||
protected $createTime = 'create_time'; // 默认添加时间字段
|
||||
protected $updateTime = 'modify_time'; // 默认编辑时间字段
|
||||
protected $deleteTime = false; // 软删除字段
|
||||
|
||||
|
||||
/**
|
||||
* Common: 设置配置信息
|
||||
* Author: wu-hui
|
||||
* Time: 2022/10/20 16:05
|
||||
* @param $params
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function setConfigInfo($params){
|
||||
try{
|
||||
$save = self::where('config_key',$params['config_key'])
|
||||
->where('app_module',$params['app_module'])
|
||||
->find();
|
||||
if(!$save){
|
||||
$save = new self();
|
||||
$save->site_id = $params['site_id'];
|
||||
$save->app_module = $params['app_module'];
|
||||
$save->config_key = $params['config_key'];
|
||||
}
|
||||
$save->value = $params['value'];
|
||||
$save->config_desc = $params['config_desc'];
|
||||
$save->is_use = $params['is_use'];
|
||||
|
||||
Cache::delete($params['config_key']);
|
||||
|
||||
return $this->success($save->save());
|
||||
}catch(Exception $e){
|
||||
return $this->error('',$e->getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Common: 获取设置
|
||||
* Author: wu-hui
|
||||
* Time: 2022/10/20 16:32
|
||||
* @param String $key
|
||||
* @param string $module
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function getConfigInfo(String $key,String $module = 'shop'){
|
||||
// 信息获取
|
||||
$info = Cache::get($key);
|
||||
if(!$info){
|
||||
$info = self::where('config_key',$key)
|
||||
->where('app_module',$module)
|
||||
->value('value');
|
||||
if($info) $info = json_decode($info, TRUE);
|
||||
$funName = camelize($key).'Default';
|
||||
if(method_exists($this,$funName)) $info = (array) $this->$funName($info);
|
||||
|
||||
Cache::set($key, $info);
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Common: 默认设置 —— 个人名片
|
||||
* Author: wu-hui
|
||||
* Time: 2022/10/20 16:32
|
||||
* @param $info
|
||||
* @return array
|
||||
*/
|
||||
public function businessCardSettingDefault($info){
|
||||
return [
|
||||
'is_examine' => $info['is_examine'] ? : 0,// 是否开启自动审核 0=否,1=是
|
||||
'customer_service' => $info['customer_service'] ? : '',// 客服二维码图片
|
||||
'agreement' => $info['agreement'] ? : '',// 用户协议
|
||||
'nickname' => $info['nickname'] ? : '名片',// 文字替换 —— 名片
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Common: 默认设置 —— 文章
|
||||
* Author: wu-hui
|
||||
* Time: 2022/10/21 15:01
|
||||
* @param $info
|
||||
* @return array
|
||||
*/
|
||||
public function articleSettingDefault($info){
|
||||
return [
|
||||
'banner_list' => $info['banner_list'] ?: [],// 轮播图
|
||||
'share' => $info['share'] ?: '分享',// 文字替换 —— 分享
|
||||
'integral' => (int)$info['integral'],// 分享文章奖励积分
|
||||
'parent_integral' => (int)$info['parent_integral'],// 直推上级奖励积分
|
||||
'max_integral' => (int)$info['max_integral'],// 每日积分获取上限
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Common: 默认设置 —— 经销商
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/06 17:24
|
||||
* @param $info
|
||||
* @return array
|
||||
*/
|
||||
public function distributorSettingDefault($info){
|
||||
return [
|
||||
'switch' => $info['switch'] ?: 0,// 是否开启
|
||||
'gradational' => $info['gradational'] ?: 0,// 级差是否开启
|
||||
'same_grade' => $info['same_grade'] ?: 0,// 平级奖是否开启
|
||||
'same_grade_ratio' => $info['same_grade_ratio'] ?: 0,// 平级奖结算比例
|
||||
'settlement_time' => $info['settlement_time'] ?: 0,// 结算时间
|
||||
'settlement_day' => $info['settlement_day'] ?: 0,// 结算天数
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Common: 默认设置 —— 区域代理
|
||||
* Author: wu-hui
|
||||
* Time: 2023/02/07 10:52
|
||||
* @param $info
|
||||
* @return array
|
||||
*/
|
||||
public function areaBonusSettingDefault($info){
|
||||
return [
|
||||
'switch' => $info['switch'] ?: 0,// 是否开启
|
||||
'province_ratio' => $info['province_ratio'] ?: 0,// 省级提成比例
|
||||
'city_ratio' => $info['city_ratio'] ?: 0,// 市级提成比例
|
||||
'district_ratio' => $info['district_ratio'] ?: 0,// 区/县提成比例
|
||||
'is_averaging' => $info['is_averaging'] ?: 0,// 是否均分
|
||||
'settlement_time' => $info['settlement_time'] ?: 0,// 结算时间
|
||||
'settlement_day' => $info['settlement_day'] ?: 0,// 结算天数
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/** ZJMall商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2022-2032 四川正今科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.zjphp.com
|
||||
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布传播。
|
||||
* 唯一发布渠道官方颁发授权证书,无纸质授权凭证书视为侵权行为。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\newModel\common;
|
||||
|
||||
use app\model\NewBaseModel;
|
||||
|
||||
class Area extends NewBaseModel{
|
||||
|
||||
protected $pk = 'id'; // 默认主键id
|
||||
protected $name = 'area';
|
||||
protected $autoWriteTimestamp = false; // 开启自动时间戳
|
||||
protected $deleteTime = false; // 软删除字段
|
||||
|
||||
/**
|
||||
* Common: 获取地区列表
|
||||
* Author: wu-hui
|
||||
* Time: 2022/10/22 18:01
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getList(){
|
||||
// 参数获取
|
||||
$pid = (int)input('pid',0);
|
||||
$isGetChildren = (boolean)input('is_get_children',false);
|
||||
// 列表信息获取
|
||||
$list = $this
|
||||
->field('id,pid,name')
|
||||
->when($isGetChildren,function($query){
|
||||
$query->with(['children'=>function($children){
|
||||
$children->field('id,pid,name');
|
||||
}]);
|
||||
})
|
||||
->where('pid',$pid)
|
||||
->where('status',1)
|
||||
->select();
|
||||
if($list) $list = $list->toArray();
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
/**
|
||||
* Common: 关联查询 当前类
|
||||
* Author: wu-hui
|
||||
* Time: 2022/10/24 9:04
|
||||
* @return \think\model\relation\HasMany
|
||||
*/
|
||||
public function children(){
|
||||
return $this->hasMany(self::class,'pid','id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
/** ZJMall商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2022-2032 四川正今科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.zjphp.com
|
||||
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布传播。
|
||||
* 唯一发布渠道官方颁发授权证书,无纸质授权凭证书视为侵权行为。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\newModel\common;
|
||||
|
||||
use think\facade\Cache as c;
|
||||
|
||||
/**
|
||||
* Common: 缓存 —— 列表数据储存专用
|
||||
* Author: wu-hui
|
||||
* Time: 2022/11/07 16:11
|
||||
* Class CaChe
|
||||
* @package app\model\newModel\common
|
||||
*/
|
||||
class CaChe{
|
||||
/**
|
||||
* Common: 生成缓存标签
|
||||
* Author: wu-hui
|
||||
* Time: 2022/11/07 16:00
|
||||
* @param array $array
|
||||
* @return string
|
||||
*/
|
||||
public static function tag(array $array){
|
||||
// 删除公共内容
|
||||
unset($array['app_type'],$array['app_type_name'],$array['token']);
|
||||
// 生成标签
|
||||
|
||||
|
||||
return md5(json_encode($array));
|
||||
}
|
||||
/**
|
||||
* Common: 储存内容
|
||||
* Author: wu-hui
|
||||
* Time: 2022/11/07 16:17
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param string $tag
|
||||
*/
|
||||
public static function set(string $name,string $value,string $tag){
|
||||
self::cacheTag($name,$tag);
|
||||
c::set($tag,$value);
|
||||
}
|
||||
/**
|
||||
* Common: 获取缓存信息
|
||||
* Author: wu-hui
|
||||
* Time: 2022/11/07 16:19
|
||||
* @param string $name
|
||||
* @param string $tag
|
||||
* @return mixed
|
||||
*/
|
||||
public static function get(string $name,string $tag){
|
||||
return c::get($tag);
|
||||
}
|
||||
/**
|
||||
* Common: 删除缓存
|
||||
* Author: wu-hui
|
||||
* Time: 2022/11/07 16:49
|
||||
* @param $name
|
||||
*/
|
||||
public static function del($name){
|
||||
$list = (array)c::get($name);
|
||||
foreach($list as $tag){
|
||||
c::delete($tag);
|
||||
}
|
||||
|
||||
c::delete($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common: 储存 缓存名称和键名称的关系
|
||||
* Author: wu-hui
|
||||
* Time: 2022/11/07 16:16
|
||||
* @param $name
|
||||
* @param $tag
|
||||
*/
|
||||
private static function cacheTag($name,$tag){
|
||||
$tagList = c::get($name);
|
||||
if(is_array($tagList)){
|
||||
if(!in_array($tag,$tagList)){
|
||||
$tagList[] = $tag;
|
||||
c::set($name,$tagList);
|
||||
}
|
||||
}else{
|
||||
c::set($name,[$tag]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
/** ZJMall商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2022-2032 四川正今科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.zjphp.com
|
||||
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布传播。
|
||||
* 唯一发布渠道官方颁发授权证书,无纸质授权凭证书视为侵权行为。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\newModel\common;
|
||||
|
||||
use addon\article\model\Article;
|
||||
use addon\article\model\ArticleShareRecord;
|
||||
use app\model\NewBaseModel;
|
||||
|
||||
class ShareRecord extends NewBaseModel{
|
||||
|
||||
protected $pk = 'id';
|
||||
//protected $autoWriteTimestamp = false; // 开启自动时间戳
|
||||
protected $createTime = 'create_time'; // 默认添加时间字段
|
||||
protected $updateTime = 'update_time'; // 默认编辑时间字段
|
||||
protected $deleteTime = false; // 软删除字段
|
||||
protected $type = [
|
||||
'time' => 'timestamp:Y-m-d H:i',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Common: 记录分享信息
|
||||
* Author: wu-hui
|
||||
* Time: 2022/11/04 15:09
|
||||
* @param $params
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function addInfo($params){
|
||||
$pathInfo = $this->handlePath($params['share_path']);
|
||||
$where['member_id'] = $params['member_id'];
|
||||
$objectName = '';
|
||||
// 信息处理
|
||||
switch($pathInfo['path']){
|
||||
// 文章详情分享
|
||||
case '/pages_aijiu/article/detail':
|
||||
$where['object_id'] = $pathInfo['article_id'];
|
||||
$where['type'] = 1;
|
||||
$objectName = (new Article())->where('article_id',$pathInfo['article_id'])->value('article_title');
|
||||
// 记录文章分享信息
|
||||
$articleRecordInfo = [
|
||||
'article_id' => $pathInfo['article_id'],
|
||||
'member_id' => $params['member_id'],
|
||||
'share_id' => $pathInfo['share_id']
|
||||
];
|
||||
(new ArticleShareRecord())->addInfo($articleRecordInfo);
|
||||
break;
|
||||
}
|
||||
// 记录分享 由于要统计每天的分享 所以这里一直为添加
|
||||
$recordInfo = $this->where($where)->find();
|
||||
if(!$recordInfo) $recordInfo = new self();
|
||||
$recordInfo->object_title = $objectName;
|
||||
$recordInfo->object_id = $where['object_id'];
|
||||
$recordInfo->member_id = $where['member_id'];
|
||||
$recordInfo->type = $where['type'];
|
||||
$recordInfo->frequency += 1;
|
||||
$recordInfo->save();
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
/**
|
||||
* Common: 处理url信息
|
||||
* Author: wu-hui
|
||||
* Time: 2022/11/04 15:05
|
||||
* @param $path
|
||||
* @return array
|
||||
*/
|
||||
private function handlePath($path){
|
||||
$fragment = parse_url($path)['fragment'];
|
||||
$pathArr = explode('?',$fragment);
|
||||
$pathInfo['path'] = $pathArr[0];
|
||||
foreach(explode('&',$pathArr[1]) as $item){
|
||||
$field = explode('=',$item);
|
||||
$pathInfo[$field[0]] = $field[1];
|
||||
}
|
||||
|
||||
return $pathInfo;
|
||||
}
|
||||
/**
|
||||
* Common: 文章分享记录
|
||||
* Author: wu-hui
|
||||
* Time: 2022/11/07 14:16
|
||||
* @return array
|
||||
*/
|
||||
public function articleRecord($memberId){
|
||||
// 参数获取
|
||||
$page = input('page',1);
|
||||
$pageSize = input('page_size',PAGE_LIST_ROWS);
|
||||
$searchText = (string)trim(input('search_text'));
|
||||
// 列表获取
|
||||
$result = $this->alias('sr')
|
||||
->field('a.article_id,a.article_title,a.cover_img,sr.update_time as time')
|
||||
->join('article a','a.article_id = sr.object_id','LEFT')
|
||||
->where('sr.type',1)
|
||||
->where('a.status',1)
|
||||
->where('a.site_id',$this->site_id)
|
||||
->where('sr.member_id',$memberId)
|
||||
->when(strlen($searchText) > 0,function($query) use ($searchText){
|
||||
$query->where('a.article_title','like',"%{$searchText}%");
|
||||
})
|
||||
->where('sr.member_id',$memberId)
|
||||
->order('sr.update_time','DESC')
|
||||
->paginate(['list_rows' => $pageSize,'page' => $page]);
|
||||
if($result) $result = $result->toArray();
|
||||
$list = [
|
||||
'count' => $result['total'],
|
||||
'list' => $result['data'],
|
||||
'page_count' => $result['last_page'],
|
||||
];
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,220 @@
|
|||
<?php
|
||||
/** ZJMall商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2022-2032 四川正今科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.zjphp.com
|
||||
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布传播。
|
||||
* 唯一发布渠道官方颁发授权证书,无纸质授权凭证书视为侵权行为。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\newModel\goods;
|
||||
|
||||
use addon\fenxiao\newModel\Fenxiao;
|
||||
use addon\supermember\model\MemberLevelOrder;
|
||||
use app\model\member\MemberAccount as MemberAccountModel;
|
||||
use app\model\NewBaseModel;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
|
||||
class Goods extends NewBaseModel{
|
||||
|
||||
protected $pk = 'id'; // 默认主键id
|
||||
protected $name = 'goods';
|
||||
protected $autoWriteTimestamp = false; // 开启自动时间戳
|
||||
protected $deleteTime = false; // 软删除字段
|
||||
|
||||
|
||||
/**
|
||||
* Common: 获取器 —— 处理商品图片
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/06 13:50
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
public function getGoodsImageAttr($value){
|
||||
$image = (string)explode(',',$value)[0];
|
||||
|
||||
return img($image);
|
||||
}
|
||||
/**
|
||||
* Common: 商品选择器 —— 商品列表获取
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/06 16:24
|
||||
* @return array
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function selectList(){
|
||||
// 参数获取
|
||||
$page = input('page',1);
|
||||
$pageSize = input('page_size',PAGE_LIST_ROWS);
|
||||
$search = input("search",'');
|
||||
$ids = input('ids','');// 已经选中的商品id
|
||||
// 列表获取
|
||||
$field = [
|
||||
'goods_id',
|
||||
'goods_name',
|
||||
'goods_image',
|
||||
'price',
|
||||
'market_price'
|
||||
];
|
||||
$result = $this
|
||||
->field($field)
|
||||
->where('site_id',$this->site_id)
|
||||
->where('is_delete',0)
|
||||
->when(!empty($search),function($query) use ($search){
|
||||
$query->where('goods_name','like',"%{$search}%");
|
||||
})
|
||||
->when(!empty($ids),function($query) use ($ids){
|
||||
$ids = explode(',',$ids);
|
||||
$query->whereNotIn('goods_id',$ids);
|
||||
})
|
||||
->order('sort DESC,goods_id DESC')
|
||||
->paginate(['list_rows' => $pageSize,'page' => $page]);
|
||||
if($result) $result = $result->toArray();
|
||||
$list = [
|
||||
'count' => $result['total'],
|
||||
'list' => $result['data'],
|
||||
'page_count' => $result['last_page'],
|
||||
];
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
/**
|
||||
* Common: 根据id数组获取商品信息
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/06 16:05
|
||||
* @param $ids
|
||||
* @param string[] $field
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getGoodsList($ids,$field = ['*']){
|
||||
$list = $this
|
||||
->field($field)
|
||||
->where('site_id',$this->site_id)
|
||||
->where('is_delete',0)
|
||||
->whereIn('goods_id',$ids)
|
||||
->order('sort DESC,goods_id DESC')
|
||||
->select();
|
||||
|
||||
return $list ? $list->toArray() : [];
|
||||
}
|
||||
/**
|
||||
* Common: 购买商品 奖励积分
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/09 17:11
|
||||
* @param $orderId
|
||||
* @param $memberId
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function buyGoodsRewardIntegral($orderId,$memberId){
|
||||
Log::debug('购买商品获取积分 ------ START ------ 订单id:'.$orderId);
|
||||
// 获取全部相关的商品
|
||||
$orderGoodsList = Db::name('order_goods')
|
||||
->field('goods_id,num,real_goods_money')
|
||||
->where('order_id',$orderId)
|
||||
->select();
|
||||
if($orderGoodsList) $orderGoodsList = $orderGoodsList->toArray();
|
||||
$orderGoodsIds = array_column($orderGoodsList,'goods_id');
|
||||
$orderGoodsList = array_column($orderGoodsList,NULL,'goods_id');
|
||||
$field = [
|
||||
'goods_id',
|
||||
'integral_switch',
|
||||
'integral_type',
|
||||
'integral',
|
||||
'integral_proportion',
|
||||
'parent_integral_proportion',
|
||||
'parent_integral_switch',
|
||||
'parent_integral_type',
|
||||
'parent_integral',
|
||||
];
|
||||
$goodsList = Db::name('goods')
|
||||
->field($field)
|
||||
->whereIn('goods_id',$orderGoodsIds)
|
||||
->select();
|
||||
if($goodsList) $goodsList = $goodsList->toArray();
|
||||
// 获取上级用户id
|
||||
$parentMemberId = (new Fenxiao())->getParentMemberId($memberId);
|
||||
// 循环处理积分奖励
|
||||
$siteId = $this->site_id;
|
||||
foreach($goodsList as $item){
|
||||
// 基本参数
|
||||
//Log::debug('购买商品获取积分 - 商品id:'.$item['goods_id']);
|
||||
$buyNum = (int)$orderGoodsList[$item['goods_id']]['num'] <= 0 ? 1 : (int)(int)$orderGoodsList[$item['goods_id']]['num'];
|
||||
$realGoodsMoney = (float)$orderGoodsList[$item['goods_id']]['real_goods_money'] <= 0 ? 1 : (float)$orderGoodsList[$item['goods_id']]['real_goods_money'];
|
||||
// 下单用户奖励积分
|
||||
if($item['integral_switch'] == 1) {
|
||||
// 积分计算类型:0=百分比,1=固定金额
|
||||
if($item['integral_type'] == 1) $integral = (float)$item['integral'] * $buyNum;
|
||||
else $integral = $realGoodsMoney * (float)($item['integral_proportion'] / 100);
|
||||
// 奖励发放
|
||||
//Log::debug('购买商品获取积分 - 下单人奖励积分:'.$integral);
|
||||
if($integral > 0){
|
||||
$remark = '购买商品奖励积分';
|
||||
(new MemberAccountModel())->addMemberAccount($siteId, $memberId, 'point', $integral, 'buy_goods', 0, $remark);
|
||||
}
|
||||
}
|
||||
// 下单用户上级奖励积分
|
||||
if($item['parent_integral_switch'] == 1 && $parentMemberId > 0) {
|
||||
// 积分计算类型:0=百分比,1=固定金额
|
||||
if($item['parent_integral_type'] == 1) $parentIntegral = (float)$item['parent_integral'] * $buyNum;
|
||||
else $parentIntegral = $realGoodsMoney * (float)($item['parent_integral_proportion'] / 100);
|
||||
// 奖励发放
|
||||
//Log::debug('购买商品获取积分 - 上级奖励积分:'.$parentIntegral);
|
||||
if($parentIntegral > 0){
|
||||
$remark = '购买商品奖励积分';
|
||||
(new MemberAccountModel())->addMemberAccount($siteId, $parentMemberId, 'point', $parentIntegral, 'buy_goods', 0, $remark);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log::debug('购买商品获取积分 ------ END ------ 订单id:'.$orderId);
|
||||
}
|
||||
/**
|
||||
* Common: 购买商品 赠送会员卡
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/13 10:38
|
||||
* @param $orderId
|
||||
* @param $memberId
|
||||
* @return false|void
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function buyGoodsGiveMemberLevel($orderId,$memberId){
|
||||
Log::debug('购买商品赠送会员卡 - 订单id:'.$orderId);
|
||||
// 获取全部的商品id
|
||||
$orderGoodsIds = Db::name('order_goods')->where('order_id',$orderId)->column('goods_id');
|
||||
$goodsMemberLevelList = Db::name('goods')
|
||||
->field('goods_id,give_member_level_id,give_member_level_index')
|
||||
->whereIn('goods_id',$orderGoodsIds)
|
||||
->where('give_member_level_id','>',0)
|
||||
->select();
|
||||
if($goodsMemberLevelList) $goodsMemberLevelList = $goodsMemberLevelList->toArray();
|
||||
else return false;
|
||||
// 循环处理数据
|
||||
$memberLevelOrderModel = new MemberLevelOrder();
|
||||
foreach($goodsMemberLevelList as $item){
|
||||
// 生成会员卡订单
|
||||
$data = [
|
||||
'level_id' => $item['give_member_level_id'],
|
||||
'period_index' => $item['give_member_level_index'],
|
||||
'member_id' => $memberId,
|
||||
'site_id' => $this->site_id,
|
||||
'purchase_method' => 'exchange',// 购买方式
|
||||
'is_balance' => 0,
|
||||
];
|
||||
$res = $memberLevelOrderModel->create($data);
|
||||
$result = $memberLevelOrderModel->offlinePay($res['data']['out_trade_no']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,250 @@
|
|||
<?php
|
||||
/** ZJMall商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2022-2032 四川正今科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.zjphp.com
|
||||
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布传播。
|
||||
* 唯一发布渠道官方颁发授权证书,无纸质授权凭证书视为侵权行为。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\newModel\member;
|
||||
|
||||
use addon\article\model\ArticleFabulous;
|
||||
use addon\article\model\ArticleHistory;
|
||||
use addon\businesscard\model\Cards;
|
||||
use addon\distributor\model\Distributor;
|
||||
use app\model\NewBaseModel;
|
||||
use app\model\newModel\common\ShareRecord;
|
||||
use app\model\newModel\Config;
|
||||
use think\facade\Db;
|
||||
|
||||
class Member extends NewBaseModel{
|
||||
|
||||
protected $pk = 'member_id'; // 默认主键id
|
||||
protected $name = 'member';
|
||||
protected $autoWriteTimestamp = false; // 开启自动时间戳
|
||||
protected $deleteTime = 'delete_time'; // 软删除字段
|
||||
|
||||
/**
|
||||
* Common: 获取器 —— 如果没有用户头像,返回默认头像
|
||||
* Author: wu-hui
|
||||
* Time: 2022/10/24 15:54
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
public function getHeadimgAttr($value){
|
||||
return $value ? img($value) : 'public/static/img/default_img/head.png';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Common: 用户选择器 —— 入口
|
||||
* Author: wu-hui
|
||||
* Time: 2022/10/20 14:53
|
||||
* @param $siteId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function selectMemberList($siteId){
|
||||
// 参数获取
|
||||
$page = input('page',1);
|
||||
$pageSize = input('page_size',PAGE_LIST_ROWS);
|
||||
$memberSearch = input("member_search",'');
|
||||
$selectType = input('select_type','');// 需要使用用户选择器的模块类型
|
||||
// 列表获取
|
||||
switch($selectType){
|
||||
case 'business_card':
|
||||
// 名片用户选择器
|
||||
$model = $this->businessCardSelect($memberSearch,$siteId);
|
||||
break;
|
||||
case 'distributor':
|
||||
// 经销商用户选择器
|
||||
$model = $this->distributorSelect($memberSearch,$siteId);
|
||||
break;
|
||||
default:
|
||||
$model = $this->defaultSelect($memberSearch,$siteId);
|
||||
}
|
||||
$result = $model->paginate(['list_rows' => $pageSize,'page' => $page]);
|
||||
if($result) $result = $result->toArray();
|
||||
$list = [
|
||||
'count' => $result['total'],
|
||||
'list' => $result['data'],
|
||||
'page_count' => $result['last_page'],
|
||||
];
|
||||
return $this->success($list);
|
||||
}
|
||||
/**
|
||||
* Common: 用戶选择器 —— 默认
|
||||
* Author: wu-hui
|
||||
* Time: 2022/10/20 14:54
|
||||
* @param $memberSearch
|
||||
* @param $siteId
|
||||
* @return Member
|
||||
*/
|
||||
private function defaultSelect($memberSearch,$siteId){
|
||||
$field = [
|
||||
'member_id',
|
||||
'headimg',
|
||||
'nickname',
|
||||
'point',
|
||||
'balance'
|
||||
];
|
||||
return $this
|
||||
->field($field)
|
||||
->where('site_id',$siteId)
|
||||
->where('is_delete',0)
|
||||
->where( 'mobile|email|nickname', 'like', "%{$memberSearch}%");
|
||||
}
|
||||
/**
|
||||
* Common: 用户选择器 —— 名片用户选择
|
||||
* Author: wu-hui
|
||||
* Time: 2022/10/20 14:52
|
||||
* @param $memberSearch
|
||||
* @param $siteId
|
||||
* @return mixed
|
||||
*/
|
||||
private function businessCardSelect($memberSearch,$siteId){
|
||||
$field = [
|
||||
'a.member_id',
|
||||
'a.headimg',
|
||||
'a.nickname',
|
||||
'a.point',
|
||||
'a.balance',
|
||||
'min(b.status) as min_status',
|
||||
'min(b.delete_time)',
|
||||
'b.id'
|
||||
];
|
||||
|
||||
return $this
|
||||
->field($field)->alias('a')
|
||||
->join('business_card b','a.member_id = b.member_id','LEFT')
|
||||
->where('a.site_id',$siteId)
|
||||
->where('a.is_delete',0)
|
||||
->having('min(b.delete_time) > 0 OR min(b.member_id) IS NULL ')
|
||||
->where('a.mobile|a.email|a.nickname', 'like', "%{$memberSearch}%")
|
||||
->order('a.member_id DESC,b.id DESC')
|
||||
->group('a.member_id');
|
||||
}
|
||||
/**
|
||||
* Common: 用户选择器 —— 经销商
|
||||
* Author: wu-hui
|
||||
* Time: 2022/11/21 18:06
|
||||
* @param $memberSearch
|
||||
* @param $siteId
|
||||
* @return mixed
|
||||
*/
|
||||
private function distributorSelect($memberSearch,$siteId){
|
||||
$field = [
|
||||
'a.member_id',
|
||||
'a.headimg',
|
||||
'a.nickname',
|
||||
'a.point',
|
||||
'a.balance'
|
||||
];
|
||||
|
||||
return $this
|
||||
->field($field)->alias('a')
|
||||
->join('distributor b','a.member_id = b.member_id','LEFT')
|
||||
->where('a.site_id',$siteId)
|
||||
->where('a.is_delete',0)
|
||||
->having('min(b.delete_time) > 0 OR min(b.member_id) IS NULL ')
|
||||
->where('a.mobile|a.email|a.nickname', 'like', "%{$memberSearch}%")
|
||||
->order('a.member_id DESC,b.id DESC')
|
||||
->group('a.member_id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Common: 获取文章详情中的显示用户信息
|
||||
* Author: wu-hui
|
||||
* Time: 2022/11/03 13:36
|
||||
* @param $memberId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getArticleMemberInfo($memberId){
|
||||
// 获取用户信息
|
||||
$info = $this
|
||||
->field('member_id,share_member,nickname,mobile,headimg,is_fenxiao,level_expire_time')
|
||||
->where('member_id',$memberId)
|
||||
->find();
|
||||
if($info) $info = $info->toArray();
|
||||
// 当前用户存在推荐人且本人不是分销商-显示推荐人信息,不存在推荐人或者本人是分销商-显示本人信息
|
||||
if($info['share_member'] > 0 && $info['is_fenxiao'] != 1){
|
||||
$shareMember = $this
|
||||
->field('nickname,mobile,headimg')
|
||||
->where('member_id',$info['share_member'])
|
||||
->find();
|
||||
$info['nickname'] = $shareMember['nickname'];
|
||||
$info['mobile'] = $shareMember['mobile'];
|
||||
$info['headimg'] = $shareMember['headimg'];
|
||||
}
|
||||
// 信息处理
|
||||
$info['nickname'] = desensitizationHandle($info['nickname'],1,0);
|
||||
$info['mobile'] = desensitizationHandle($info['mobile'],3,4);
|
||||
// 当:本人不是分销商或者会员卡已过期-显示升级名片,本人是分销商且会员卡未过期-显示我要分享
|
||||
if($info['is_fenxiao'] != 1 || $info['level_expire_time'] <= time())$info['show_type'] = 'upgrade';
|
||||
else $info['show_type'] = 'share';
|
||||
|
||||
return $info;
|
||||
}
|
||||
/**
|
||||
* Common: 获取个人名片中的个人中心的用户信息
|
||||
* Author: wu-hui
|
||||
* Time: 2022/11/04 16:42
|
||||
* @param $memberId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function getBusinessCardInfo($memberId){
|
||||
// 获取用户信息
|
||||
$field = [
|
||||
'm.member_id',
|
||||
'm.headimg',
|
||||
'm.nickname as member_nickname',
|
||||
'm.level_expire_time',
|
||||
'm.member_level_name',
|
||||
'm.balance_money',
|
||||
'bc.id as card_id',
|
||||
'bc.is_show',
|
||||
'bc.auto_examine',
|
||||
'bc.agreement',
|
||||
];
|
||||
$info = (new Cards())->getSingleInfo($memberId,$field)['data'];
|
||||
$info['level_status'] = 0; // 未开通
|
||||
// 会员卡是否有效
|
||||
if($info['level_expire_time'] > time()) {
|
||||
$info['level_status'] = 1; // 正常
|
||||
$info['level_expire_time'] = date('Y-m-d',$info['level_expire_time']);
|
||||
}else if($info['level_expire_time'] > 0 && $info['level_expire_time'] <= time()){
|
||||
$info['level_status'] = 2; // 过期
|
||||
}
|
||||
// 获取统计信息
|
||||
$info['total_share'] = (new ShareRecord())->where('member_id',$memberId)->where('type',1)->count();
|
||||
$info['total_fabulous'] = (new ArticleFabulous())->where('member_id',$memberId)->count();
|
||||
$info['total_history'] = (new ArticleHistory())->where('member_id',$memberId)->count();
|
||||
$info['integral'] = (new Member())->where('member_id',$memberId)->value('point');
|
||||
// 获取名片设置信息
|
||||
$info['set'] = (new Config())->getConfigInfo('BUSINESS_CARD_SETTING');
|
||||
// 获取可提现金额
|
||||
$info['account'] = (float)$info['balance_money'];
|
||||
|
||||
return $this->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common: 关联会员卡
|
||||
* Author: wu-hui
|
||||
* Time: 2022/10/28 17:19
|
||||
* @return \think\model\relation\HasOne
|
||||
*/
|
||||
public function level(){
|
||||
return $this->hasOne(MemberLevel::class,'level_id','member_level');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/** ZJMall商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2022-2032 四川正今科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.zjphp.com
|
||||
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布传播。
|
||||
* 唯一发布渠道官方颁发授权证书,无纸质授权凭证书视为侵权行为。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\newModel\member;
|
||||
|
||||
use app\model\NewBaseModel;
|
||||
|
||||
class MemberLevel extends NewBaseModel{
|
||||
|
||||
protected $pk = 'level_id'; // 默认主键id
|
||||
protected $name = 'member_level';
|
||||
protected $autoWriteTimestamp = false; // 开启自动时间戳
|
||||
protected $deleteTime = false; // 软删除字段
|
||||
private $levelName = [
|
||||
'week' => '周',
|
||||
'month' => '月',
|
||||
'quarter' => '季',
|
||||
'year' => '年',
|
||||
];
|
||||
|
||||
/**
|
||||
* Common: 获取会员卡详细信息
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/13 17:27
|
||||
* @param $id
|
||||
* @param $index
|
||||
* @return MemberLevel|array|mixed|\think\Model|null
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getDetails($id,$index){
|
||||
$info = $this
|
||||
->field('level_id,level_name,charge_rule')
|
||||
->where('level_id',$id)
|
||||
->find();
|
||||
if($info) $info = $info->toArray();
|
||||
$info['current_rule'] = json_decode($info['charge_rule'],true)[$index];
|
||||
|
||||
return $info;
|
||||
}
|
||||
/**
|
||||
* Common: 获取某个会员卡的规格
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/23 17:20
|
||||
* @param $levelId
|
||||
* @return array
|
||||
*/
|
||||
public function getChargeRule($levelId){
|
||||
$chargeRule = $this->where('level_id',$levelId)->value('charge_rule');
|
||||
if(!$chargeRule) return [];
|
||||
$levelName = $this->levelName;
|
||||
return array_map(function($item) use ($levelName){
|
||||
$item['unit'] = $levelName[$item['date-cycle']];
|
||||
$item['title'] = $item['date-num'].$levelName[$item['date-cycle']].'卡';
|
||||
|
||||
return $item;
|
||||
},json_decode($chargeRule,TRUE));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
<?php
|
||||
/** ZJMall商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2022-2032 四川正今科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.zjphp.com
|
||||
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布传播。
|
||||
* 唯一发布渠道官方颁发授权证书,无纸质授权凭证书视为侵权行为。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\newModel\member;
|
||||
|
||||
use app\model\NewBaseModel;
|
||||
use app\model\newModel\Config;
|
||||
use app\model\newModel\goods\Goods;
|
||||
use app\model\order\OrderCreate as OrderCreateModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class MemberLevelPopularize extends NewBaseModel{
|
||||
|
||||
protected $pk = 'id'; // 默认主键id
|
||||
protected $name = 'member_level_popularize';
|
||||
protected $autoWriteTimestamp = true; // 开启自动时间戳
|
||||
protected $createTime = 'create_time'; // 默认添加时间字段
|
||||
protected $updateTime = 'update_time'; // 默认编辑时间字段
|
||||
protected $deleteTime = false; // 软删除字段
|
||||
|
||||
/**
|
||||
* Common: 编辑信息
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/13 18:05
|
||||
* @param $memberId
|
||||
* @param $levelId
|
||||
* @param $levelIndex
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function editPopularizeInfo($memberId,$levelId,$levelIndex){
|
||||
$where = [
|
||||
['site_id','=',$this->site_id],
|
||||
['member_id','=',$memberId],
|
||||
['level_id','=',$levelId],
|
||||
['level_index','=',$levelIndex],
|
||||
];
|
||||
$info = self::where($where)->find();
|
||||
if($info) {
|
||||
self::update(['member_id'=>$memberId], $where);
|
||||
}
|
||||
else{
|
||||
$data = [
|
||||
'member_id' => $memberId,
|
||||
'site_id' => $this->site_id,
|
||||
'level_id' => $levelId,
|
||||
'level_index' => $levelIndex,
|
||||
];
|
||||
|
||||
self::create($data);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Common: 获取可用名额
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/13 18:15
|
||||
* @param $memberId
|
||||
* @return int
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function availableQuotaTotal($memberId){
|
||||
$set = (new Config())->getConfigInfo('SUPERMEMBER_POPULARIZE');
|
||||
$fenXiaoId = Db::name('fenxiao')
|
||||
->where('member_id',$memberId)
|
||||
->where('is_delete',0)
|
||||
->value('fenxiao_id');
|
||||
if($fenXiaoId <= 0) return 0;
|
||||
|
||||
return (int)Db::name('fenxiao')->alias('fx')
|
||||
->join('member_level_popularize mlp','mlp.member_id = fx.member_id','LEFT')
|
||||
->where('fx.parent',$fenXiaoId)
|
||||
->where('fx.is_delete',0)
|
||||
->where('mlp.is_use',0)
|
||||
->where('mlp.level_id',$set['give_member_level_id'])
|
||||
->where('mlp.level_index',$set['give_member_level_index'])
|
||||
->count();
|
||||
}
|
||||
/**
|
||||
* Common: 获取全部下级
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/13 18:33
|
||||
* @param $memberId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function getWholeSubMember($memberId){
|
||||
// 基本信息
|
||||
$page = input('page',1);
|
||||
$pageSize = input('page_size',PAGE_LIST_ROWS);
|
||||
$set = (new Config())->getConfigInfo('SUPERMEMBER_POPULARIZE');
|
||||
$fenXiaoId = Db::name('fenxiao')
|
||||
->where('member_id',$memberId)
|
||||
->where('is_delete',0)
|
||||
->value('fenxiao_id');
|
||||
if($fenXiaoId <= 0) return [];
|
||||
// 列表获取
|
||||
$field = [
|
||||
'm.member_id',
|
||||
'fx.fenxiao_id',
|
||||
'm.nickname',
|
||||
'm.headimg',
|
||||
];
|
||||
$result = Db::name('fenxiao')->alias('fx')
|
||||
->join('member m','m.member_id = fx.member_id','LEFT')
|
||||
->field($field)
|
||||
->where('fx.parent',$fenXiaoId)
|
||||
->where('fx.is_delete',0)
|
||||
->order('fx.fenxiao_id','DESC')
|
||||
->paginate(['list_rows' => $pageSize,'page' => $page]);
|
||||
if($result) {
|
||||
$result = $result->toArray();
|
||||
// 获取:用户是否购买指定会员卡
|
||||
$memberIds = array_column($result['data'],'member_id');
|
||||
$popularizeList = $this->whereIn('member_id',$memberIds)
|
||||
->where('level_id',$set['give_member_level_id'])
|
||||
->where('level_index',$set['give_member_level_index'])
|
||||
->column('id','member_id');
|
||||
$result['data'] = array_map(function($item) use ($popularizeList){
|
||||
$item['popularize_id'] = $popularizeList[$item['member_id']] ?? 0;
|
||||
|
||||
return $item;
|
||||
},$result['data']);
|
||||
}
|
||||
|
||||
$list = [
|
||||
'count' => $result['total'],
|
||||
'list' => $result['data'],
|
||||
'page_count' => $result['last_page'],
|
||||
];
|
||||
return $this->success($list);
|
||||
}
|
||||
/**
|
||||
* Common: 根据用户id获取最早的指定数量的购买指定会员卡的信息id
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/14 15:18
|
||||
* @param $memberId
|
||||
* @param $limit
|
||||
* @return array|int
|
||||
*/
|
||||
public function availableQuotaIds($memberId,$limit){
|
||||
$set = (new Config())->getConfigInfo('SUPERMEMBER_POPULARIZE');
|
||||
$fenXiaoId = Db::name('fenxiao')
|
||||
->where('member_id',$memberId)
|
||||
->where('is_delete',0)
|
||||
->value('fenxiao_id');
|
||||
if($fenXiaoId <= 0) return [];
|
||||
|
||||
return Db::name('fenxiao')->alias('fx')
|
||||
->join('member_level_popularize mlp','mlp.member_id = fx.member_id','LEFT')
|
||||
->where('fx.parent',$fenXiaoId)
|
||||
->where('fx.is_delete',0)
|
||||
->where('mlp.is_use',0)
|
||||
->where('mlp.level_id',$set['give_member_level_id'])
|
||||
->where('mlp.level_index',$set['give_member_level_index'])
|
||||
->order('id','ASC')
|
||||
->limit($limit)
|
||||
->column('mlp.id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/** ZJMall商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2022-2032 四川正今科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.zjphp.com
|
||||
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布传播。
|
||||
* 唯一发布渠道官方颁发授权证书,无纸质授权凭证书视为侵权行为。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\newModel\member;
|
||||
|
||||
use app\model\NewBaseModel;
|
||||
use app\model\newModel\Config;
|
||||
use app\model\newModel\goods\Goods;
|
||||
use app\model\order\OrderCreate as OrderCreateModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class MemberLevelPrize extends NewBaseModel{
|
||||
|
||||
protected $pk = 'id'; // 默认主键id
|
||||
protected $name = 'member_level_prize';
|
||||
protected $autoWriteTimestamp = false; // 开启自动时间戳
|
||||
protected $deleteTime = false; // 软删除字段
|
||||
|
||||
|
||||
/**
|
||||
* Common: 存储领取记录(领取前)
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/14 14:53
|
||||
* @param $memberId
|
||||
* @param $cardIds
|
||||
* @param $popularizeNum
|
||||
*/
|
||||
public function addInfo($memberId,$cardIds,$popularizeNum){
|
||||
$data = [
|
||||
'member_id' => $memberId,
|
||||
'site_id' => $this->site_id,
|
||||
'cart_id' => implode(',',$cardIds),
|
||||
'order_id' => 0,
|
||||
'is_get' => 0,
|
||||
'popularize_num' => $popularizeNum,
|
||||
'create_time' => time()
|
||||
];
|
||||
$this->insert($data);
|
||||
}
|
||||
/**
|
||||
* Common: 处理领奖名额信息
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/14 15:28
|
||||
* @param $out_trade_no
|
||||
* @param $cardIdStr
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function handleInfo($out_trade_no,$cardIdStr){
|
||||
// 获取信息
|
||||
$orderInfo = Db::name('order')
|
||||
->field('order_id,member_id')
|
||||
->where('out_trade_no',$out_trade_no)
|
||||
->find();
|
||||
$popularizeNum = $this->where('cart_id',$cardIdStr)->value('popularize_num');
|
||||
// 处理名额信息
|
||||
$ids = (new MemberLevelPopularize())->availableQuotaIds($orderInfo['member_id'],$popularizeNum);
|
||||
(new MemberLevelPopularize())->whereIn('id',$ids)->update(['is_use' => 1]);
|
||||
$this->where('cart_id',$cardIdStr)->update(['is_get'=>1]);
|
||||
}
|
||||
/**
|
||||
* Common: 获取领奖次数
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/14 20:46
|
||||
* @param $memberId
|
||||
* @return int
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function isGetTotal($memberId){
|
||||
return (int)$this->where('member_id',$memberId)->where('is_get',1)->count();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1615,4 +1615,20 @@ class Goods extends BaseShop
|
|||
return $express_template_list;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Common: 商品选择器
|
||||
* Author: wu-hui
|
||||
* Time: 2022/12/06 16:45
|
||||
* @return array|mixed
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function selectGoods(){
|
||||
if(request()->isAjax()) return (new \app\model\newModel\goods\Goods())->selectList();// 查询信息
|
||||
|
||||
$this->assign('ids',input('ids'));
|
||||
return $this->fetch('goods/select_goods');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
{extend name="app/shop/view/base.html"/}
|
||||
{block name="resources"}
|
||||
<style>
|
||||
#selectMemberContent {
|
||||
padding: 0 30px;
|
||||
}
|
||||
</style>
|
||||
{/block}
|
||||
|
||||
{block name="body"}
|
||||
<div id="selectMemberContent">
|
||||
<!-- 搜索框 -->
|
||||
<div class="single-filter-box top">
|
||||
<div class="layui-form">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="member_search" placeholder="请输入商品名称" autocomplete="off" class="layui-input">
|
||||
<button id="searchButton" type="button" class="layui-btn layui-btn-primary" lay-filter="search" lay-submit>
|
||||
<i class="layui-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 列表 -->
|
||||
<table id="goodsList" lay-filter="goodsList"></table>
|
||||
<!--子窗体保存值的临时控件-->
|
||||
<input type="hidden" id="selectGoodsInfo" value="" />
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<a class="layui-btn" lay-event="selected">确认选中</a>
|
||||
</script>
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
{block name="script"}
|
||||
<script>
|
||||
var form, table,ids = "{$ids}";
|
||||
layui.use(['form'], function() {
|
||||
// 基本参数
|
||||
_thisIndex = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
|
||||
form = layui.form;
|
||||
form.render();
|
||||
table = new Table({
|
||||
elem: '#goodsList',
|
||||
url: ns.url("shop/goods/selectGoods", { ids:ids }),
|
||||
cols: [
|
||||
[{
|
||||
title: '商品信息',
|
||||
unresize: 'false',
|
||||
align:'center',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
html += `<img src="${data.goods_image}" />`;
|
||||
return html;
|
||||
}
|
||||
}, {
|
||||
field: 'goods_name',
|
||||
title: '商品名称',
|
||||
unresize: 'false',
|
||||
align:'center'
|
||||
},{
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'center'
|
||||
}]
|
||||
]
|
||||
});
|
||||
//监听工具栏操作
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
if(obj.event === 'selected') $("#selectGoodsInfo").val(JSON.stringify(data));
|
||||
// 关闭弹框
|
||||
parent.layer.close(_thisIndex); //再执行关闭
|
||||
});
|
||||
//搜索功能
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
Loading…
Reference in New Issue