随着美业市场的不断发展和壮大,对于美业管理系统的需求也越来越高。美业管理系统是一款针对美容美发行业而设计的应用软件,主要功能包括预约管理、顾客管理、会员管理、收银管理、库存管理等,它可以帮助美业企业实现更高效、更精准、更智能的管理。
美业系统源码
<?php
declare (strict_types=1);
namespace app\beautiful\controller\cashier;
use app\BaseController;
use app\beautiful\helper\payment\PaymentMicropayHelper;
use app\beautiful\logic\LogsLogic;
use app\beautiful\logic\MemberWalletLogic;
use app\beautiful\logic\order\OrderCashierLogic;
use app\beautiful\logic\printer\PrinterLogic;
use app\beautiful\model\member\MemberCouponModel;
use app\beautiful\model\member\MemberModel;
use app\beautiful\model\order\CashierOrderItemModel;
use app\beautiful\model\order\CashierOrderModel;
use app\common\logic\DataLogic;
use think\facade\Db;
class Order extends BaseController{
public function getOrderList()
{
$where=[
['shop_id','=',$this->request->shopId],
['is_delete','=',0],
];
if(!empty($order_id)) $where[]=['order_id','=',$order_id];
if(!empty($order_type)) $where[]=['order_type','=',$order_type];
if(!empty($status)) $where[]=['status','=',$status];
$order_model=new CashierOrderModel();
$order_model=$order_model->with(['skus','member']);
$order=['add_time'=>'desc'];
$field="*";
$append=['add_time_format','pay_time_format','status_means','pay_type_mean'];
$return = DataLogic::getDataList($order_model,$where,$order,$field,$this->request->limit,$this->request->page,$append);
return $this->success($return);
}
public function getOrderDetail()
{
$order_id = $this->request->param('order_id/d',0);
if($order_id==0) return $this->error('订单不存在#1');
if(null === $order = CashierOrderModel::find($order_id)) return $this->error('订单不存在#2');
if($order->shop_id != $this->request->shopId) return $this->error('订单不存在#3');
if($order->is_delete != 0) return $this->error('订单不存在#4');
$member = MemberModel::find($order->member_id);
$items=CashierOrderItemModel::where([
['shop_id','=',$this->request->shopId],
['order_id','=',$order_id]
])->select()->toArray();
if(empty($items)) return $this->error('订单不存在#7');
$order->append(['add_time_format','pay_time_format','status_means','pay_type_mean']);
$detail=[
'order_id'=>$order->order_id,
'add_time_format'=>$order->add_time_format,
'status'=>$order->status,
'status_means'=>$order->status_means,
'need_pay'=>$order->need_pay,
'pay_type'=>$order->pay_type,
'pay_type_mean'=>$order->pay_type_mean,
'pay_time_format'=>$order->pay_time_format,
'total_price'=>$order->total_price,
'youhui_balance'=>$order->youhui_price,
'coupon_money'=>$order->coupon_money,
'member'=>$member,
'member_name'=>$member === null ? '-' :$member->nick_name,
'member_mobile'=>$member === null ? '-' :$member->mobile,
'items'=>$items
];
return $this->success(['detail'=>$detail]);
}
public function createOrder()
{
$member_id = $this->request->param('member_id/d',0);
$total_price = $this->request->param('total_price/f',0);
$coupon_id = $this->request->param('coupon_id/d',0);
$youhui_price=$this->request->param('youhui_price/f',0);
$goods=$this->request->param('goods/a',[]);
$params=[
'member_id'=>$member_id,
'total_price'=>$total_price,
'coupon_id'=>$coupon_id,
'youhui_price'=>$youhui_price,
'goods'=>$goods,
];
Db::startTrans();
try{
$order_cashier_logic = new OrderCashierLogic($this->request->shopId);
$order_id=$order_cashier_logic->createOrder($params);
Db::commit();
return $this->success(['order_id'=>$order_id]);
} catch(\Exception $e){
Db::rollback();
return $this->error($e->getMessage());
}
}
public function moneyPay()
{
$order_id = $this->request->param('order_id/d');
if(empty($order_id)){
return $this->error('请选择要支付的订单');
}
if( null === $order = CashierOrderModel::find($order_id)){
return $this->error('订单不存在');
}
if($order->status != 1 || $order->is_delete == 1){
return $this->error('订单不在未支付状态');
}
if($order->member_id == 0){
return $this->error('游客不能使用余额支付#1');
}
if(null === $member = MemberModel::find($order->member_id)){
return $this->error('游客不能使用余额支付#2');
}
if($member->shop_id != $this->request->shopId){
return $this->error('游客不能使用余额支付#3');
}
Db::startTrans();
try{
if(!empty($order->member_coupon_id)){
if(null === $myCoupon = MemberCouponModel::find($order->member_coupon_id)){
Db::rollback();
return $this->error('优惠券不存在');
}
if($myCoupon->status == 1){
Db::rollback();
return $this->error('优惠券不存在');
}
$myCoupon->status = 1;
$myCoupon->save();
LogsLogic::coupon($this->request->shopId, $order->member_id, -1, 12, $order->member_coupon_id, '', 0);
}
$MemberWalletLogic = new MemberWalletLogic($this->request->shopId, $member->member_id);
$needPay = round(($order->total_price * 100 + - $order->coupon_money * 100 - $order->youhui_price * 100)/100,2);
if($needPay < 0){
Db::rollback();
$this->error('支付金额不正确');
}
if($needPay!=0){
$res = $MemberWalletLogic->useBalance($needPay, $order->total_price , 8); //商城购物使用
if($res == false){
Db::rollback();
return $this->error($MemberWalletLogic->getError());
}
}
$order->pay_time = time();
$order->status = 2; //订单的状态值
$order->pay_type = 'money';
$order->save();
$this->usePrinter($order);
Db::commit();
return $this->success('余额支付成功');
}catch(\Exception $e){
Db::rollback();
return $this->error($e->getMessage());
}
}
public function cashPay()
{
$order_id = $this->request->param('order_id/d');
if(empty($order_id)){
return $this->error('请选择要支付的订单');
}
if( null === $order = CashierOrderModel::find($order_id)){
return $this->error('订单不存在');
}
if($order->status != 1 || $order->is_delete == 1){
return $this->error('订单不在未支付状态');
}
if($order->member_id != 0){
if(null === $member = MemberModel::find($order->member_id)){
return $this->error('会员不存在');
}
if($member->shop_id != $this->request->shopId){
return $this->error('会员不存在');
}
}
Db::startTrans();
try{
if($order->member_id != 0){
if(!empty($order->member_coupon_id)){
if(null === $myCoupon = MemberCouponModel::find($order->member_coupon_id)){
Db::rollback();
return $this->error('优惠券不存在');
}
if($myCoupon->status == 1){
Db::rollback();
return $this->error('优惠券不存在');
}
$myCoupon->status = 1;
$myCoupon->save();
LogsLogic::coupon($this->request->shopId, $order->member_id, -1, 12, $order->member_coupon_id, '', 0);
}
}
$needPay = round(($order->total_price * 100 + - $order->coupon_money * 100 - $order->youhui_price * 100)/100,2);
if($needPay <= 0){
Db::rollback();
$this->error('支付金额不正确');
}
$order->pay_time = time();
$order->status = 2; //订单的状态值
$order->pay_type = 'cash';
$order->save();
$this->usePrinter($order);
Db::commit();
return $this->success('现金支付成功');
}catch(\Exception $e){
Db::rollback();
return $this->error($e->getMessage());
}
}
public function scanPay()
{
$auth_code=$this->request->param('auth_code');
$order_id=$this->request->param('order_id');
if(empty($order_id)){
return $this->error('请选择要支付的订单');
}
if( null === $order = CashierOrderModel::find($order_id)){
return $this->error('订单不存在');
}
if($order->status != 1 || $order->is_delete == 1){
return $this->error('订单不在未支付状态');
}
try{
$payment = new PaymentMicropayHelper($this->request->shopId);
$return =$payment->sendPayment([
'product_name'=>'扫码支付',
'order_id'=>$order_id,
'need_pay'=>$order->need_pay,
'auth_code'=>$auth_code,
]);
if($return['return_code'] === 'SUCCESS'){
// if($return['result_code'] === 'SUCCESS'){
//
// }else{
// return $this->error($return['err_code_des']);
// }
return $this->success($return);
}
return $this->error($return['return_msg']);
} catch(\Exception $e){
return $this->error($e->getMessage());
}
}
public function queryOrder()
{
$order_id=$this->request->param('order_id');
if(empty($order_id)){
return $this->error('请选择要支付的订单');
}
if( null === $order = CashierOrderModel::find($order_id)){
return $this->error('订单不存在');
}
if($order->status != 1 || $order->is_delete == 1){
return $this->error('订单不在未支付状态');
}
try {
$payment = new PaymentMicropayHelper($this->request->shopId);
$return =$payment->queryOrder($order_id);
if($return['return_code'] === 'SUCCESS'){
if($return['result_code'] === 'SUCCESS'){
if($return['trade_state'] === 'SUCCESS'){
$order->pay_time = time();
$order->pay_type = 'weixin';
$order->status=2;
$order->save();
$this->usePrinter($order);
}
}
return $this->success($return);
}
return $this->error($return['return_msg']);
}catch(\Exception $e){
return $this->error($e->getMessage());
}
}
public function cancelPay()
{
$order_id=$this->request->param('order_id');
if(empty($order_id)){
return $this->success('成功');
}
if( null === $order = CashierOrderModel::find($order_id)){
return $this->success('成功');
}
if($order->status != 1 || $order->is_delete == 1){
return $this->success('成功');
}
$payment = new PaymentMicropayHelper($this->request->shopId);
$return =$payment->cancelPay($order_id);
$order->status=-1;
$order->save();
return $this->success('成功');
}
public function cancelOrder()
{
$order_id=$this->request->param('order_id');
if(empty($order_id)){
return $this->error('请选择要支付的订单');
}
if( null === $order = CashierOrderModel::find($order_id)){
return $this->error('订单不存在');
}
if($order->status != 1 || $order->is_delete == 1){
return $this->error('订单不在未支付状态');
}
$order->status=-1;
$order->save();
return $this->success('成功');
}
protected function usePrinter($order)
{
//打印机
$printer_logic =new PrinterLogic($this->request->shopId);
$printer_logic->print('cashOrder',$order->order_id);
}
}
美业管理系统的主要功能包括:
-
预约管理:通过美业管理系统,企业可以快速方便地进行预约管理,包括在线预约、电话预约、微信预约等方式,避免因为手工操作而导致的预约冲突和失误。
-
顾客管理:通过美业管理系统,企业可以对顾客信息进行完整的管理,包括信息采集、客户档案等,同时还可以进行顾客分类、分析和营销活动等。
-
会员管理:通过美业管理系统,企业可以方便地管理会员信息,包括积分、等级、优惠等,提高会员的满意度和忠诚度,增加重复消费率。
-
收银管理:通过美业管理系统,企业可以实现电子收银,方便快捷地完成收银操作,避免了因为手工操作产生的错误和纠纷。
-
库存管理:通过美业管理系统,企业可以实现库存管理,包括进货、出货、盘点等操作,提高库存管理的效率和精度。
美业管理系统的优势包括:
-
提高管理效率:通过美业管理系统,企业可以实现自动化的管理,减少手工操作的繁琐和错误,提高管理效率。
-
增加客户满意度:通过美业管理系统,企业可以更好地管理顾客信息,提供更多的个性化服务,增加顾客的满意度。
-
提高经营数据分析能力:通过美业管理系统,企业可以实现经营数据的收集、分析和报表展示,为企业的决策提供更有力的支持。
如何开发美业管理系统呢?
-
需求分析:开发前需要对美业管理系统的功能和需求进行充分的调研和分析,明确开发目标和方向。
-
技术选型:选择适合的技术框架和工具,包括数据库、服务器、前端开发、后端开发等。
-
系统设计:根据需求分析结果,进行系统设计,包括软件架构设计、数据库设计、界面设计等。
-
开发实现:按照系统设计方案进行开发实现,并进行各个模块的联调和测试。
-
上线运营:经过测试和优化后,将美业管理系统上线运营,并进行后期维护和升级。
总之,美业管理系统是美容美发行业必备的管理工具,它可以帮助企业提高管理效率、增加客户满意度、提高经营数据分析能力。开发美业管理系统需要充分考虑美业行业特点和用户需求,选择适合的技术框架和工具,进行全面系统的设计和开发实现,最终使美业管理系统能够帮助企业实现更高效、更精准、更智能的管理。