diff --git a/addon/store/config/menu_shop.php b/addon/store/config/menu_shop.php index b9e79cb5..6f3754f3 100644 --- a/addon/store/config/menu_shop.php +++ b/addon/store/config/menu_shop.php @@ -5,7 +5,6 @@ * Copy right 2019-2029 成都云之牛科技有限公司, 保留所有权利。 * ---------------------------------------------- * 官方网址: https://www.cdcloudshop.com - * ========================================================= */ return [ @@ -48,75 +47,75 @@ return [ ] ] ], - [ - 'name' => 'SERVICE_YUYUE', - 'title' => '预约', - 'url' => 'store://shop/reserve/index', - 'parent' => 'ORDER_ROOT', - 'is_show' => 1, - 'is_control' => 0, - 'is_icon' => 0, - 'picture' => 'iconyuyueguanli', - 'picture_select' => '', - 'sort' => 3, - 'child_list' => [ - [ - 'name' => 'YUYUE_MAMAGE', - 'title' => '预约管理', - 'url' => 'store://shop/reserve/index', - 'is_show' => 1, - 'is_control' => 1, - 'is_icon' => 0, - 'picture' => 'iconyuyueguanli', - 'picture_select' => '', - 'sort' => 1, - 'child_list' => [ - [ - 'name' => 'YUYUE_INDEX', - 'title' => '预约看板', - 'url' => 'store://shop/reserve/index', - 'is_show' => 1, - 'sort' => 1, - ], - [ - 'name' => 'YUYUE_LISTS', - 'title' => '预约管理', - 'url' => 'store://shop/reserve/lists', - 'is_show' => 1, - 'sort' => 2, - 'child_list' => [ - [ - 'name' => 'YUYUE_DETAIL', - 'title' => '预约详情', - 'url' => 'store://shop/reserve/detail', - 'is_show' => 0 - ], - [ - 'name' => 'YUYUE_CONFIRM', - 'title' => '确认预约', - 'url' => 'store://shop/reserve/confirm', - 'is_show' => 0 - ], - [ - 'name' => 'YUYUE_CANCEL', - 'title' => '取消预约', - 'url' => 'store://shop/reserve/cancel', - 'is_show' => 0 - ], - [ - 'name' => 'YUYUE_TO_STORE', - 'title' => '确认到店', - 'url' => 'store://shop/reserve/confirmtostore', - 'is_show' => 0 - ] - ] - ] - - ] - ], - - ] - ], +// [ +// 'name' => 'SERVICE_YUYUE', +// 'title' => '预约', +// 'url' => 'store://shop/reserve/index', +// 'parent' => 'ORDER_ROOT', +// 'is_show' => 1, +// 'is_control' => 0, +// 'is_icon' => 0, +// 'picture' => 'iconyuyueguanli', +// 'picture_select' => '', +// 'sort' => 3, +// 'child_list' => [ +// [ +// 'name' => 'YUYUE_MAMAGE', +// 'title' => '预约管理', +// 'url' => 'store://shop/reserve/index', +// 'is_show' => 1, +// 'is_control' => 1, +// 'is_icon' => 0, +// 'picture' => 'iconyuyueguanli', +// 'picture_select' => '', +// 'sort' => 1, +// 'child_list' => [ +// [ +// 'name' => 'YUYUE_INDEX', +// 'title' => '预约看板', +// 'url' => 'store://shop/reserve/index', +// 'is_show' => 1, +// 'sort' => 1, +// ], +// [ +// 'name' => 'YUYUE_LISTS', +// 'title' => '预约管理', +// 'url' => 'store://shop/reserve/lists', +// 'is_show' => 1, +// 'sort' => 2, +// 'child_list' => [ +// [ +// 'name' => 'YUYUE_DETAIL', +// 'title' => '预约详情', +// 'url' => 'store://shop/reserve/detail', +// 'is_show' => 0 +// ], +// [ +// 'name' => 'YUYUE_CONFIRM', +// 'title' => '确认预约', +// 'url' => 'store://shop/reserve/confirm', +// 'is_show' => 0 +// ], +// [ +// 'name' => 'YUYUE_CANCEL', +// 'title' => '取消预约', +// 'url' => 'store://shop/reserve/cancel', +// 'is_show' => 0 +// ], +// [ +// 'name' => 'YUYUE_TO_STORE', +// 'title' => '确认到店', +// 'url' => 'store://shop/reserve/confirmtostore', +// 'is_show' => 0 +// ] +// ] +// ] +// +// ] +// ], +// +// ] +// ], [ 'name' => 'STORE_LIST', 'title' => '门店管理', diff --git a/app/api/controller/Memberwithdraw.php b/app/api/controller/Memberwithdraw.php index 16dcd754..e969d165 100644 --- a/app/api/controller/Memberwithdraw.php +++ b/app/api/controller/Memberwithdraw.php @@ -7,18 +7,14 @@ * 官方网址: https://www.cdcloudshop.com * ========================================================= */ - namespace app\api\controller; - use app\model\member\Withdraw as WithdrawModel; use app\model\member\Member as MemberModel; - /** * 会员提现 */ class Memberwithdraw extends BaseApi { - /** * 会员提现信息 */ @@ -26,20 +22,22 @@ class Memberwithdraw extends BaseApi { $token = $this->checkToken(); if ($token[ 'code' ] < 0) return $this->response($token); - $member_model = new MemberModel(); - $member_info_result = $member_model->getMemberInfo([ [ 'member_id', '=', $token[ 'data' ][ 'member_id' ] ] ], 'site_id,balance_money,balance_withdraw_apply,balance_withdraw'); + $member_info_result = $member_model->getMemberInfo([ [ 'member_id', '=', $token[ 'data' ][ 'member_id' ] ] ], 'site_id,balance,balance_money,balance_withdraw_apply,balance_withdraw,pay_password'); + $member_info_result['data']['is_pay_password'] = 1; + if($member_info_result['data']['pay_password'] == ''){ + $member_info_result['data']['is_pay_password'] = 0; + } + unset($member_info_result['data']['pay_password']); $config_model = new WithdrawModel(); $config_result = $config_model->getConfig($member_info_result[ 'data' ][ 'site_id' ], 'shop'); $config = $config_result[ "data" ][ 'value' ]; $config[ 'is_use' ] = $config_result[ "data" ][ 'is_use' ]; - $data = array ( "member_info" => $member_info_result[ "data" ], "config" => $config ); return $this->response($this->success($data)); - } /** @@ -144,4 +142,44 @@ class Memberwithdraw extends BaseApi return $this->response($list); } + + /*** + * 会员互转 + * @return false|string + */ + public function balanceTransfer(){ + $token = $this->checkToken(); + if ($token['code'] < 0) return $this->response($token); + $to_username = input('username'); + $apply_money = abs(input('apply_money')); + $password = input('password',''); + if($password == ''){ + return $this->response($this->error('未填写支付密码')); + } + $to_where=[ + ['site_id' , '=',$this->site_id], + ['username|mobile','=',$to_username], + ]; + if($to_username){ + $member_model = new MemberModel(); + // 获取接收者信息 + $to_member_info = $member_model->getMemberInfo($to_where, 'member_id,site_id,balance,balance_withdraw_apply,balance_withdraw,nickname,status,pay_password'); + if(empty($to_member_info['data'])||$to_member_info['data']['status']!=1) return $this->response($this->error('会员账号不存在')); + if($this->member_id==$to_member_info['data']['member_id']) return $this->response($this->error('不能转账给自己')); + // 获取转让人信息 + $member_info_result = $member_model->getMemberInfo([['member_id', '=', $token['data']['member_id']]], 'balance,username,nickname,status,pay_password'); + if($member_info_result['data']['pay_password'] == ''){ + return $this->response(error(-801,'您未设置支付密码,需设置支付密码后进行转账,点击确定前往支付密码设置')); + } + if(data_md5($password) != $member_info_result['data']['pay_password']) return $this->response($this->error('支付密码错误')); + if($apply_money>$member_info_result['data']['balance']) return $this->response($this->error('账号余额不足')); + if($member_info_result['data']['status']!=1) return $this->response($this->error('未知错误')); + + $withdraw_model = new WithdrawModel(); + $result = $withdraw_model->MemberBalanceTransfer($member_info_result,$apply_money,$this->member_id,$to_member_info['data']['member_id'],$this->site_id,$to_member_info); + return $this->response($result); + }else{ + return $this->response($this->error('转入账号不能为空')); + } + } } \ No newline at end of file diff --git a/app/model/member/Withdraw.php b/app/model/member/Withdraw.php index 803f523e..bb950e1c 100644 --- a/app/model/member/Withdraw.php +++ b/app/model/member/Withdraw.php @@ -55,68 +55,91 @@ class Withdraw extends BaseModel 'transfer_type' => '', 'is_auto_transfer' => 0, 'min' => 0, - 'max' =>0, + 'max' => 0, + 'money_num' => 0, + 'time_week' => 0, ]; } return $res; } /**************************************************************************** 会员提现设置 *************************************************************/ + /**************************************************************************** 会员提现设置 *************************************************************/ /** * 申请提现 * @param $data */ public function apply($data, $site_id = 0, $app_module = 'shop') { - $config_result = $this->getConfig($site_id, $app_module); - $config = $config_result["data"]['value']; + $config = $config_result["data"]['value']; if ($config_result["data"]["is_use"] == 0) return $this->error([], "提现未开启"); - + if ($config['time_week']) { + $time_week = explode(',', $config['time_week']); + if (!in_array(date('w'), $time_week)) { + return $this->error([], "不在提现日,请在提现日申请"); + } + } + if ($config['money_num']) { + $time = mktime(0, 0, 0, date('m'), date('d'), date('Y')); + $where = [ + ['member_id', '=', $data["member_id"]], + ['status', 'in', [1, 2]], + ['apply_time', '>=', $time], + ]; + $conunt = model("member_withdraw")->getCount($where, 'id'); + if ($conunt >= $config['money_num']) { + return $this->error([], '超出每日提现次数'); + } + } $withdraw_no = $this->createWithdrawNo(); $apply_money = round($data["apply_money"], 2); if ($apply_money < $config["min"]) - return $this->error([], "申请提现金额不能小于最低提现额度" . $config["min"]); - if($apply_money > $config['max']) return $this->error([], "申请提现金额不能大于最高提现额度" . $config["max"]); - $member_id = $data["member_id"]; - $member_model = new Member(); + return $this->error([], "最小提现金额为¥" . $config["min"]); + if ($apply_money > $config['max']) return $this->error([], "最大提现金额为¥" . $config["max"]); + if ($config["money_multiple"] && $apply_money % $config["money_multiple"]) { + return $this->error([], "提现金额为{$config["money_multiple"]}倍数"); + } + $member_id = $data["member_id"]; + $identity = $data["identity"]; + $member_model = new Member(); $member_info_result = $member_model->getMemberInfo([["member_id", "=", $member_id]], "balance_money,headimg,wx_openid,username,mobile,weapp_openid,nickname"); - $member_info = $member_info_result["data"]; + $member_info = $member_info_result["data"]; if (empty($member_info)) return $this->error([], "MEMBER_NOT_EXIST"); - $balance_money = $member_info["balance_money"]; if ($apply_money > $balance_money) return $this->error([], "申请提现金额不能大于会员可提现金额"); - $transfer_type = $data["transfer_type"]; + $transfer_type = $data["transfer_type"]; $transfer_type_list = $this->getTransferType($site_id, $app_module); - $transfer_type_name = $transfer_type_list[$transfer_type] ?? ''; + $transfer_type_name = $transfer_type_list[$transfer_type]; if (empty($transfer_type_name)) return $this->error([], "不支持的提现方式"); - model('member_withdraw')->startTrans(); try { - $rate = $config["rate"]; - $bank_name = ""; + $rate = $config["rate"]; + $bank_name = ""; $account_number = ""; $applet_type = 0; switch ($transfer_type) { case "bank": - $bank_name = $data["bank_name"]; + $bank_name = $data["bank_name"]; $account_number = $data["account_number"]; - + if (empty($identity)) { + return $this->error('', '请绑定身份证号码'); + } break; case "alipay": - $bank_name = ''; + $bank_name = ''; $account_number = $data["account_number"]; break; case "wechatpay": $bank_name = ''; - if(empty($member_info["wx_openid"]) && empty($member_info["weapp_openid"])){ - return $this->error('','请绑定微信或更换提现账户'); + if (empty($member_info["wx_openid"]) && empty($member_info["weapp_openid"])) { + return $this->error('', '请绑定微信或更换提现账户'); } - if(!empty($member_info["wx_openid"])){ + if (!empty($member_info["wx_openid"])) { $account_number = $member_info["wx_openid"]; $applet_type = 0; // 公众号 } else { @@ -126,54 +149,72 @@ class Withdraw extends BaseModel break; } - $service_money = round($apply_money * $rate / 100, 2);//手续费 - $money = $apply_money - $service_money; - $data = array( - "site_id" => $site_id, - "withdraw_no" => $withdraw_no, - "member_name" => $member_info["username"] == '' ? $member_info["mobile"] : $member_info["username"], - "member_id" => $data["member_id"], - "transfer_type" => $data["transfer_type"], + $money = $apply_money - $service_money; + $data = array( + "site_id" => $site_id, + "withdraw_no" => $withdraw_no, + "member_name" => $member_info["username"] == '' ? $member_info["mobile"] : $member_info["username"], + "member_id" => $data["member_id"], + "transfer_type" => $data["transfer_type"], "transfer_type_name" => $transfer_type_name, - "apply_money" => $apply_money, - "service_money" => $service_money, - "rate" => $rate, - "money" => $money, - "apply_time" => time(), - "status" => 0, - "status_name" => "待审核", - "member_headimg" => $member_info["headimg"], - "realname" => $data["realname"], - "bank_name" => $bank_name, - "account_number" => $account_number, - "mobile" => $data["mobile"], - "applet_type" => $applet_type + "apply_money" => $apply_money, + "service_money" => $service_money, + "rate" => $rate, + "money" => $money, + "apply_time" => time(), + "status" => 0, + "status_name" => "待审核", + "member_headimg" => $member_info["headimg"], + "realname" => $data["realname"], + "bank_name" => $bank_name, + "account_number" => $account_number, + "identity" => $identity, + "mobile" => $data["mobile"], + "applet_type" => $applet_type ); - //减少现金余额 $member_account = new MemberAccount(); $account_res = $member_account->addMemberAccount($site_id, $member_id, 'balance_money', -$apply_money, 'withdraw', '会员提现', '会员提现扣除'); if ($account_res['code'] != 0) return $account_res; - //增加提现中余额 model("member")->setInc([["member_id", "=", $member_id]], "balance_withdraw_apply", $apply_money); - - $result = model("member_withdraw")->add($data); - + $result = model("member_withdraw")->add($data); //是否启用自动通过审核(必须是微信) if ($config["is_auto_audit"] == 0) { - $this->agree([["id", "=", $result],['site_id', '=',$site_id ]]); + $this->agree([["id", "=", $result], ['site_id', '=', $site_id]]); } - model('member_withdraw')->commit(); - //申请提现发送消息 $data['keywords'] = 'USER_WITHDRAWAL_APPLY'; $data['member_name'] = $member_info['nickname']; $message_model = new Message(); $message_model->sendMessage($data); + return $this->success(); + } catch (\Exception $e) { + model('member_withdraw')->rollback(); + return $this->error('', $e->getMessage()); + } + } + /*** + * 会员余额互转 + * @param $memberInfo + * @param $apply_money + * @param $member_id + * @param $to_member_id + * @param $site_id + * @return array + */ + public function MemberBalanceTransfer($memberInfo, $apply_money, $member_id, $to_member_id, $site_id, $to_member_info) + { + try { + //减少可提现余额 + $member_account = new MemberAccount(); + $member_account->addMemberAccount($site_id, $member_id, 'balance', -$apply_money, 'transfer', "{$to_member_id}_会员转账", "给会员{$to_member_info['data']['nickname']}转账" . (-$apply_money)); + //增加转账余额 + $account_res = $member_account->addMemberAccount($site_id, $to_member_id, 'balance', $apply_money, 'transfer', "{$member_id}_会员转账", $memberInfo['data']['nickname'] . '转账' . (+$apply_money)); + if ($account_res['code'] != 0) return $account_res; return $this->success(); } catch (\Exception $e) { model('member_withdraw')->rollback(); diff --git a/app/shop/controller/Memberwithdraw.php b/app/shop/controller/Memberwithdraw.php index 94a4d8e5..353db8ca 100644 --- a/app/shop/controller/Memberwithdraw.php +++ b/app/shop/controller/Memberwithdraw.php @@ -27,23 +27,30 @@ class Memberwithdraw extends BaseShop { $config_model = new MemberWithdrawModel(); if (request()->isAjax()) { - if (empty(input("transfer_type"))) { $transfer_type = ""; } else { $transfer_type = implode(",", input("transfer_type")); } + $time_week = input('time_week', ''); + if (!empty($time_week)) { + $time_week = implode(',', $time_week); + } //订单提现 $data = [ 'is_auto_audit' => input('is_auto_audit', 0),//是否需要审核 1 手动审核 2 自动审核 'rate' => input('rate', 0),//提现手续费比率 (0-100) 'transfer_type' => $transfer_type,//转账方式, 'is_auto_transfer' => input('is_auto_transfer', 0),//是否自动转账 1 手动转账 2 自动转账 + 'is_user_transfer' => input('is_user_transfer', 0),//是否会员互转 'min' => input('min', 0),//提现最低额度 'max' => input('max', 0),//提现最高额度 + 'money_multiple' => input('money_multiple', 0),//提现最高额度 + 'money_num' => input('money_num', 0),//提现次数限制 + 'time_week' => $time_week,//提现最高额度 ]; $this->addLog("设置会员提现配置"); - $is_use = input("is_use", 0);//是否启用 + $is_use = input("is_use", 0);//否启用 $res = $config_model->setConfig($data, $is_use, $this->site_id, $this->app_module); return $res; } else { @@ -51,6 +58,14 @@ class Memberwithdraw extends BaseShop $this->assign("is_exist", addon_is_exit("memberwithdraw", $this->site_id)); //会员提现 $config_result = $config_model->getConfig($this->site_id, $this->app_module); + if(!isset($config_result[ 'data' ]['value']['is_user_transfer'])){ + $config_result[ 'data' ]['value']['is_user_transfer']=0; + } + if (!empty($config_result[ 'data' ]['value']['time_week'])) { + $timeweek=$config_result[ 'data' ]['value']['time_week']; + $config_result[ 'data' ]['value']['time_week'] = explode(',',$timeweek); + } + $this->assign('time_week',$config_result[ 'data' ]['value']['time_week']??[]); $this->assign('config', $config_result[ 'data' ]); $pay_model = new Pay(); $transfer_type_list = $pay_model->getTransferType($this->site_id); @@ -58,7 +73,6 @@ class Memberwithdraw extends BaseShop return $this->fetch('memberwithdraw/config'); } } - /** * 会员提现列表 * @return mixed diff --git a/app/shop/view/index/index.html b/app/shop/view/index/index.html index 5091477e..7541c64a 100644 --- a/app/shop/view/index/index.html +++ b/app/shop/view/index/index.html @@ -4,45 +4,7 @@ {/block} {block name="main"} -{if isset($sms_num) && $sms_num < 500} -
- -
店铺剩余短信条数 {$sms_num} 条,如需正常发送短信,请订购短信套餐立即订购
-
-{/if} -{if $is_new_version == 1} -
- -
小程序已更新,为了不影响您的使用请尽快下载小程序上传更新
-
-{/if} - -
- -
-
- -{if $is_new_domain == 1} -
- -
检测到店铺域名发生变化,为了不影响您的使用,请尽快 部署网站(手机端、电脑端、手机商家管理端、微信小程序等上传更新)独立部署除外
-
-{/if} - -{if $shop_status.shop_pc_status == 0 || $shop_status.shop_h5_status == 0 || $shop_status.shop_weapp_status == 0} -
- -
该商城{if $shop_status.shop_pc_status == 0}pc端、{/if}{if $shop_status.shop_h5_status == 0}h5端、{/if}{if $shop_status.shop_weapp_status == 0}小程序端{/if}为关闭状态,用户无法访问。 点击跳转开启
-
-{/if} - -{if $img_extension_error} -
- -
检测到当前配置的图片处理引擎为imagemagick,但未检测到该扩展,为了不影响您的使用,请安装该扩展或切换为使用GD库
-
-{/if} {if !$guide_close}
diff --git a/app/shop/view/memberwithdraw/config.html b/app/shop/view/memberwithdraw/config.html index 7af01314..d9de351d 100644 --- a/app/shop/view/memberwithdraw/config.html +++ b/app/shop/view/memberwithdraw/config.html @@ -17,6 +17,14 @@
+ +
+ +
+ +
+
+ {if $is_exist}
@@ -29,9 +37,9 @@
-
- -
+
+ +
%
比率必须为0-100的整数
@@ -55,14 +63,48 @@
+
+ +
+
+ +
+
+
提现倍数,用户最低提现为提现金额的倍数
+
+ +
+ +
+
+ +
+
+
当日提现次数限制,0无限制
+
+ +
+ +
+
+ + + + + + + +
+
+
+
{foreach $transfer_type_list as $k => $v} - + {/foreach} -
@@ -75,13 +117,13 @@